remix-run/react-router · error · Error
Prerender (resource): Received a ${response.status} status c
Error message
Prerender (resource): Received a ${response.status} status code from `entry.server.tsx` while prerendering the `${pathname}` path.\n${new TextDecoder().decode(contents)} What it means
Thrown in `postProcess` when `metadata.type === "resource"`. Resource routes (routes that export a `loader`/`action` but no `default` component) must return HTTP 200 when prerendered; any other status is fatal because the prerendered file would contain an error body instead of the intended resource payload. The error message decodes the response bytes for diagnostics.
Source
Thrown at packages/react-router-dev/vite/plugin.ts:2585
path: pathname,
contents: data,
},
],
// After saving the .data file, request the HTML page.
// The data is passed along to be embedded in the response header.
requests: !metadata.isResourceRoute
? [createRouteRequest(metadata.path, ctx.reactRouterConfig, data)]
: [],
};
}
// Handle resource route responses
if (metadata.type === "resource") {
let pathname = new URL(request.url).pathname;
let contents = new Uint8Array(await response.arrayBuffer());
if (response.status !== 200) {
throw new Error(
`Prerender (resource): Received a ${response.status} status code from ` +
`\`entry.server.tsx\` while prerendering the \`${pathname}\` ` +
`path.\n${new TextDecoder().decode(contents)}`,
);
}
return [
{
path: pathname,
contents,
},
];
}
// Handle document responses (html or spa)
let html = await response.text();
if (metadata.type === "spa") {View on GitHub (pinned to 1fd704a7da)
Solutions
- Visit the resource URL directly in preview to inspect the body and underlying error.
- Ensure the resource loader succeeds (200) for every prerendered path.
- Drop the failing path from the `prerender` list, or wrap its loader to return deterministic content at build time.
- Verify `entry.server.tsx` does not return a custom error `Response` for resource routes.
Example fix
// before: resource route 500s during prerender
export const loader = async () => {
const data = await db.query(); // throws if DB down
return json(data);
};
// after: return a deterministic fallback at build time
export const loader = async ({ request }) => {
if (import.meta.env.PROD && !process.env.DATABASE_URL) {
return json(CACHED_FEED);
}
return json(await db.query());
}; Defensive patterns
Strategy: validation
Validate before calling
const assertResourceOk = (status: number, path: string) => {
if (status !== 200) throw new Error(`Resource ${path} returned ${status}`);
}; Prevention
- Resource routes listed in `prerender` must return 200 for every prerendered path.
- Provide deterministic fallbacks when external data is unavailable at build time.
- Don't prerender resource routes that legitimately 404 for some paths.
When it happens
Trigger: A resource route's loader throws or returns a non-200 status for a path in `prerender`; a resource route used as an API endpoint that 404s for the prerendered path; `entry.server.tsx` returns an error response for resource paths.
Common situations: Prerendering an RSS/sitemap/JSON resource route whose loader errors on missing data; hitting a resource route that conditionally 404s; CI build with DB unavailable causing the loader to fail.
Related errors
- Prerender (data): Received a ${response.status} status code
- Prerender (html): Received a ${response.status} status code
- SPA Mode: Received a ${response.status} status code from `en
- Invalid route exports found when prerendering with `ssr:fals
- Prerender: Request failed for ${prerenderPath}: ${response.s
AI-assisted analysis of remix-run/react-router@1fd704a7da (2026-08-12).
Data as JSON: /api/errors/978637aa8f527ea3.
Report an issue: GitHub.