Diagnostics
LUM5001: Request API used during prerender
A request API is used while a route is prerendered: a static route, or an spa page with export const prerender = true.
Severity: error · Category: routing and server (5xxx)
Reported by: lumiose build, while it prerenders static routes and spa pages with
prerender.
#What it means
static routes (the default) and spa pages with prerender are rendered at build time, where
there is no request: no cookies,
headers, query string or locals. Using request(), cookies(), locals(), response() or
url().searchParams there (or ctx.request, ctx.cookies and ctx.locals in a static endpoint
or headers(ctx)) cannot work, and the build stops. Middleware still runs for prerendered routes
and may read the (empty) request; only route code is checked.
#Example
export default function Home() {
const theme = cookies().get("theme");
return <h1 class={theme}>Home</h1>;
}#How to fix it
Render the route per request: export const mode = "server"; (for an spa page, remove
prerender or set export const prerender = false). Or keep the route prerendered and move the
request-dependent part into an island (in an spa page, onMount() or an event handler) that
reads it in the browser or calls an endpoint.