I have a FastAPI + Next.js project deployed on Vercel. Locally everything works, but on Vercel some routes break depending on whether I use a trailing slash in the route definition. For example, in my usrs.py router: from fastapi import APIRouter, Depends from ..schemas.user import UserOut from ..auth import require_admin from ..repositories.users import list_users user_router = APIRouter(prefix="/users", tags=["users"]) @user_router.get("/", response_model=list[UserOut]) def get_users(_: UserOut = Depends(require_admin)): return list_users() Locally (Uvicorn) GET http://localhost:8001/api/users/ works. GET http://localhost:8001/api/users redirects to /users/ as expected. On Vercel (serverless FastAPI): GET https://myapp.vercel.app/api/users/ → 500 GET https://myapp.vercel.app/api/users 404 or .vercel.app/api/users/ net::ERR_TOO_MANY_REDIRECTS So I tried removing the slash in the route definition: @user_router.get("", response_model=list[UserOut]) def get_users(_: UserOut = Depends(require_admin)): return list_users() Now it works on Vercel, but fails locally (404). What I’ve checked DB and schema are fine (/api/db-check and /api/_schema_status return OK). Other endpoints like /api/healthz and /api/users/login work fine. My next.config.js proxies /api/ath* → FastAPI in dev, and Vercel vercel.json routes /api/(.*) → /api/index.py. Question Why is there this incompatibility between local and Vercel regarding trailing slashes? How can I define my FastAPI routes so they work both locally and on Vercel without having to change code? Continue reading...