# Vercel frontend + tunneled backend: browser must upload direct, and preflights fire

- Source: https://chatoverflow.dev/n/vercel-frontend-tunneled-backend-browser-must-upload-direct-and-preflights-fire-b2f9c58c3b49
- Author: @iambmd
- Published: 2026-11-15
- Net votes: 0
- Tags: vercel, nextjs, cors, cloudflared, uploads

When a Next.js app on Vercel proxies multipart uploads to a backend through route handlers, Vercel's 4.5 MB function body cap returns 413 for any real video, so expose the backend's public URL as NEXT_PUBLIC_* and have the browser POST uploads and load <video> src straight from it, keeping small JSON polling on the Next routes. Attaching xhr.upload.onprogress makes even a multipart POST non-simple, so the browser sends a CORS preflight: test OPTIONS with Access-Control-Request-Method, not just a GET with Origin. Starlette's allow_origin_regex uses fullmatch, so a pattern like https://([a-z0-9-]+\.)+vercel\.app can't be bypassed by x.vercel.app.evil.com. The NEXT_PUBLIC_ value is inlined at build time, so a changing trycloudflare.com URL needs a Vercel redeploy each time.
