Prompt

How do I execute redirects and auth checks at the network edge?

Technology / CDN & Edge Infrastructure1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

To do redirects and auth checks at the network edge, you typically put that logic in a CDN / edge function / reverse proxy layer so requests are handled before they reach your origin app.

Common ways to do it

1. CDN / Edge Functions

Use a provider’s edge runtime to inspect the request and either:

  • return a redirect immediately
  • allow the request through
  • reject it with 401/403
  • attach headers or tokens

Examples:

  • Cloudflare Workers
  • Vercel Edge Middleware
  • Netlify Edge Functions
  • AWS CloudFront Functions / Lambda@Edge
  • Fastly Compute
  • Akamai EdgeWorkers

2. Reverse Proxy Rules

If you control the proxy layer, you can do this with:

  • Nginx
  • Envoy
  • Traefik
  • Apache
  • API gateways like Kong, Apigee, AWS API Gateway

These can enforce:

  • path-based redirects
  • host-based redirects
  • JWT validation
  • header checks
  • IP allow/deny rules

Typical flow

  1. Request arrives at the edge
  2. Edge code checks:
    • path
    • host
    • cookies
    • auth headers
    • JWT/session token
    • geo/IP/device rules
  3. Edge returns:
    • 301/302/307/308 redirect, or
    • 401/403 unauthorized/forbidden, or
    • forwards to origin

Example: redirect at the edge

Pseudo-code:

if (request.url.pathname === "/old-page") {
  return Response.redirect("https://example.com/new-page", 301);
}

Example: auth check at the edge

Pseudo-code:

const token = request.headers.get("Authorization");

if (!token || !isValid(token)) {
  return new Response("Unauthorized", { status: 401 });
}

Important considerations

  • Keep checks fast: edge code should be lightweight.
  • Avoid calling origin unless necessary.
  • Use signed cookies/JWTs instead of session DB lookups when possible.
  • Cache redirect decisions where safe.
  • Be careful with secrets: store them in edge secrets/vars, not hardcoded.
  • Preserve HTTP semantics:
    • use 301/308 for permanent redirects
    • use 302/307 for temporary redirects
  • Watch for open redirects: validate redirect destinations.

If you want a practical setup

Tell me which platform you’re using, for example:

  • Cloudflare
  • Vercel
  • AWS CloudFront
  • Nginx
  • Next.js
  • Fastly

and I can give you a concrete implementation.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.