Diagnostics
LUM5008: Folder middleware covering prerendered routes
A folder middleware.ts covers routes that are prerendered at build time.
Severity: warning · Category: routing and server (5xxx)
Reported by: the route scanner (lumiose check, lumiose routes, the dev server and
lumiose build), once per middleware file, listing the prerendered routes it covers.
#What it means
Folder middleware runs whenever the app handles a route, the same rule src/middleware.ts
follows: per request for server routes, for every route in lumiose dev, and at build time for
prerendered ones (static pages and endpoints, and spa pages with prerender). Production
serves a prerendered route's file without the app, so its middleware never sees those requests.
That is fine for headers and the HTML it shapes at build time, but a check meant to guard the
route (auth, a feature flag, a redirect) protects nothing in production, although it seems to work
in lumiose dev.
#Example
src/routes/admin/middleware.ts redirects visitors who are not signed in
src/routes/admin/page.stsx mode "static" (the default): prerendered, served as a file#How to fix it
Render the routes the middleware protects per request: export const mode = "server" in the
page, in a layout above it, or for the whole app with lumiose({ mode: "server" }). If the
middleware only adds headers or rewrites HTML at build time, move the prerendered routes out of
its folder, or let the warning stand.