EDGE Signal 88
FastAPI frontends and static files served from the CDN
Vercel now serves FastAPI frontends and static files directly from its CDN without invoking serverless functions for those paths.
This reduces latency and serverless function invocations for static assets and frontend routes. Engineers must account for route precedence and dependency checks, which may keep some files on the function. The change simplifies deployment but requires configuration adjustments for edge cases.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
FastAPI frontends and static files are promoted to Vercel CDN at build time, bypassing serverless functions for those requests
Route declaration order in FastAPI determines precedence, with earlier routes overriding CDN-served static files at the same path
Dependencies and middleware prevent CDN promotion unless explicitly overridden in configuration
THE READ
What the cluster adds up to.
Vercel has changed how FastAPI applications handle static files and frontend routes. These assets are now automatically moved to the CDN during the build process. This means requests for these paths no longer trigger Vercel Functions, reducing latency and function invocations. The change applies to both `app.frontend()` and `StaticFiles` mounts, which are now served directly from the edge network by default.
The shift introduces new considerations for route precedence. FastAPI evaluates routes in declaration order, so any route defined before a `StaticFiles` mount will take priority over CDN-served files at that path. This preserves existing behavior but requires engineers to review their route definitions. For example, a `/static/manifest.json` endpoint will still be handled by the function if declared before the `/static` mount, even if the file exists in the static directory.
Not all static files or frontend routes will be promoted to the CDN. Files guarded by dependencies or sitting behind middleware remain on the function, as the CDN cannot execute dependency checks or middleware logic. This limitation can be overridden with `tool.vercel.fastapi.static.cdn = true` in `pyproject.toml`, but doing so may break functionality that relies on server-side checks. Conversely, setting the flag to `false` opts out of CDN promotion entirely.
The promoted source directories are still included in the function bundle by default, allowing the application to read from them at runtime if needed. To exclude them and serve exclusively from the CDN, engineers must set `tool.vercel.fastapi.static.exclude = true`. This trade-off between bundle size and runtime access must be evaluated based on the application's requirements. The change simplifies serving static assets but introduces configuration complexity for edge cases.
Written by elseif from the cluster below · checked for specifics the sources never containedTHE CLUSTER
↗