Prompt
What should I use for auth and redirects at the edge?
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
If you want auth + redirects at the edge, the usual best choice is:
Recommended setup
- Edge auth: JWT or signed cookie validation in middleware/edge functions
- Redirects: static redirect rules at the CDN/edge when possible, and middleware/edge functions for conditional redirects
Good options by platform
Vercel
- Next.js Middleware for auth-gating and redirects
- Edge Functions if you need custom logic
- Use Auth.js / NextAuth with JWT/session cookies for auth checks
Cloudflare
- Cloudflare Workers
- For auth, validate:
- JWTs
- session cookies
- HMAC-signed tokens
- For redirects, use:
- Workers for dynamic redirects
- Rules/Redirect Rules for simple static redirects
Fastly
- Compute@Edge
- Great for low-latency auth decisions and redirects
Netlify
- Edge Functions
- Redirects via
netlify.tomlfor simple cases - Edge functions for protected routes
What to avoid
- Don’t do full auth database lookups on every edge request if you can avoid it.
- Prefer:
- stateless tokens
- short-lived signed cookies
- cached session validation
- Keep redirects simple and deterministic if possible.
Practical recommendation
If you’re building a modern web app:
- Use cookie-based auth with a JWT or signed session cookie
- Validate it in edge middleware
- Use centralized redirect rules for simple path mapping
- Use edge logic only for conditional redirects like:
- logged-out users to
/login - locale-based redirects
- subscription-based gating
- logged-out users to
If you tell me your stack, I can suggest the exact implementation:
- Next.js / Vercel
- Cloudflare
- AWS
- Netlify
- something else