Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Configure a Vercel project routing rule to rewrite /api requests to an external origin.

A collection of web tools to make your life easier. Made with Next.js and Chakra UI.

Automatically optimizes images used in Nuxt.js projects (JPEG, PNG, SVG, WebP and GIF).

Open-source React and Flutter component library monorepo built on Ark UI, Tailwind CSS, and shadcn/ui, with 36 ready-to-use components.

A Laravel 7+ package that tracks UTM parameters and referrers to attribute user registrations.
Add API External Origin Routing Rule is a Vercel CDN configuration template that creates a project-level rewrite rule, proxying all requests under /api to an external backend without code changes or redeployment.
This template produces a rewrite rule for the Vercel CDN layer. It takes a path pattern (/api/:path*) and a destination URL (https://api.example.com/$1), and outputs a published routing rule on your Vercel project. The rule can be configured through the Vercel Dashboard, CLI, REST API, or SDK, and it is part of Vercel's curated examples collection.
/api/:path* and rewrites them to an external origin.CDN-Cache-Control headers to cache responses at the edge.Vercel-Cache-Tag headers for targeted cache purging.vercel routes add), REST API, or SDK./api requests to a dedicated API server, maintaining same-origin for browsers and simplifying CORS.https://api.example.com/$1 with your actual backend URL.The same rule can be created via the CLI by running vercel routes add with the source pattern, action, and destination, then vercel routes publish.
The template itself is free to use, but Vercel's platform may have associated costs for CDN usage, caching, and firewall features depending on your plan.
It rewrites all requests matching /api/:path* on your Vercel domain to an external origin URL, proxying the traffic through Vercel's CDN.
Yes, you can adjust /api/:path* to match your specific API paths and update the destination URL to point to any external backend.
Add a CDN-Cache-Control header in the response to cache responses at the edge, or use Vercel-Cache-Tag for targeted cache purging.
Yes, you can define routing rules in code using vercel.ts for version control, as shown in the Proxy requests to external origins template.