Python projects can now use routing rules to set response headers or rewrite requests to internal paths, including apps built with FastAPI, Django, and Flask.
The Vercel CDN evaluates rules before requests reach your application, so changes apply without a new deployment.
For example, this FastAPI app serves a /new route:
from fastapi import FastAPI
app = FastAPI ( )
@app . get ( "/new" )
def new_route ( ) - > dict [ str , str ] :
return { "message" : "New route!" }
Defines the /new route the rewrite below targets
To send requests for /old to that route, create a rewrite from the CDN tab in your project dashboard or with the Vercel CLI :
# Add a rewrite (staged automatically)
vercel routes add --ai "Rewrite /old to /new" --yes
# Review staged changes
vercel routes list --diff
# Publish to production
vercel routes publish
Creating and publishing a rewrite with the Vercel CLI
Published rules take effect immediately across all regions, and you can roll back to a previous version from the…