LabscoMCP early access ↗

Code that runs on Vercel's network the moment a request arrives, before anything is served from cache — used to send a visitor to a different page, vary it by country, or add headers to the response.

WHEN TO USE

SCOPE

USE FOR

  • Redirect or rewrite a request to a country-specific route before it hits the cache.
  • Run an A/B test by reading a variant flag and rewriting to the matching page.
  • Inject a custom header like CORS or CSP on every matching request.
  • Update routing rules like headers or rewrites without triggering a redeploy.
  • Choose between Routing Middleware, the Next.js proxy, and Edge Functions.

NOT FOR

  • Full Node.js APIs in a Next.js app — use proxy.ts instead.
  • General-purpose edge compute — use Edge Functions instead.
  • Heavy business logic or database queries — use server-side framework features.
  • Auth as the sole layer of protection — pair it with Server Components or Route Handlers.