Blog
Vercel Edge Middleware: CORS headers, rewrites, and locale routing without breaking preflight
Middleware runs before your route handlers; duplicate CORS logic carefully so OPTIONS and GET share the same origin policy.
1 min read
verceledgecors
Matcher patterns
Overly broad matchers can attach headers to static assets unintentionally—tighten regexes.
Exclude Next.js image optimizer paths unless you truly need cross-origin embedding.
Streaming responses
Edge streaming can flush headers early; ensure Vary: Origin is present before the first chunk for credentialed fetches.
Test middleware order when combining auth, i18n, and CORS in one file.
