TanStack's server bundle already exposes `.fetch(request)`. Vercel's
Web API handler pattern (per the docs) invokes that method on the
default export, passing a real Web Request — so we can skip the
hand-rolled IncomingMessage→Request adapter entirely.
Vercel's Node runtime hands the function an IncomingMessage-shaped object:
path-only `.url`, plain-object `.headers`, Node Readable `.body`. TanStack's
H3 server wants a Web-standard Request. Convert headers to a Headers
instance, rebuild an absolute URL from the host header, and bridge the
Node stream body to a web ReadableStream via Readable.toWeb.
Vercel's Node runtime passes a Request-like object where `.url` is
path-only (IncomingMessage semantics). TanStack's H3Event constructor
calls new URL(req.url) and crashes with ERR_INVALID_URL. Reconstruct
the URL from the host header before forwarding.
Keep the base-path-prefixed rewrites for assets and routes that Vite
already baked the prefix into, but also emit root-level rewrites so
bare-domain hits (including /) resolve to the shell instead of Vercel's
default 404.
The @vercel/config 0.2.1 CLI spreads named exports as top-level keys
(except a small allowlist). `export const config` ends up nested as
`{"config": {"rewrites": [...]}}` in the compiled JSON — Vercel can't
find the rewrites at the top level. Default export matches what the
implementation actually expects despite the docs example suggesting
otherwise. Also swapped plain rewrite objects for the routes.rewrite
helper for type-safety on future additions.