{"record":{"id":"0893f9a9e496c491","repo":"remix-run/react-router","slug":"prerender-data-received-a-response-status-st-0893f9","errorCode":null,"errorMessage":"Prerender (data): Received a ${response.status} status code from `entry.server.tsx` while prerendering the `${url.pathname}` path.\n${url.pathname}","messagePattern":"Prerender \\(data\\): Received a (.+?) status code from `entry\\.server\\.tsx` while prerendering the `(.+?)` path\\.\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/vite/rsc/plugin.ts","lineNumber":770,"sourceCode":"        }\n\n        return Array.from(prerenderPaths).map(\n          (prerenderPath) =>\n            `http://localhost${basename}${prerenderPath.slice(1)}`,\n        );\n      },\n      async postProcess(request, response, metadata) {\n        let url = new URL(request.url);\n\n        let isRedirect = redirectStatusCodes.has(response.status);\n\n        if (\n          !isRedirect &&\n          response.status !== 200 &&\n          response.status !== 202 &&\n          !(url.pathname === \"/__spa-fallback.html\" && response.status === 404)\n        ) {\n          throw new Error(\n            `Prerender (data): Received a ${response.status} status code from ` +\n              `\\`entry.server.tsx\\` while prerendering the \\`${url.pathname}\\` ` +\n              `path.\\n${url.pathname}`,\n            { cause: response },\n          );\n        }\n\n        if (metadata?.manifest) {\n          return [\n            {\n              path: url.pathname,\n              contents: await response.text(),\n            },\n          ];\n        }\n\n        let isHtml = response.headers\n          .get(\"content-type\")","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/rsc/plugin.ts#L752-L788","documentation":"Thrown by the postProcess hook of the RSC prerender pipeline when entry.server.tsx returns an unexpected HTTP status. Allowed statuses are: 200, 202, redirect codes (301,302,303,307,308), and 404 specifically for the /__spa-fallback.html SPA path. Any other status (e.g. 500, 404 on a real route, 401) aborts prerendering for that path, with the response attached as `cause`.","triggerScenarios":"During prerendering (data mode + RSC), entry.server.tsx's render handler throws or returns an error Response (status 500, 403, etc.). A loader/action returning a non-redirect error Response. A 404 on a path that isn't the SPA fallback (route not matched but not in SPA mode).","commonSituations":"A loader throws during prerender because it expects runtime data unavailable at build time (env vars, DB). A route returns 401/403 for unauthenticated prerender requests. Misconfigured prerender paths that include routes with no matching loader. SSR errors (thrown in entry.server.tsx render) surfacing as 500.","solutions":["Read err.cause (the Response) and its body — it usually contains the server-rendered error stack or loader message.","If a loader needs build-time data, guard it with `import.meta.env` and provide prerender-safe fallbacks.","Exclude the failing path from prerender config (prerender array / staticPaths) until the loader is prerender-safe.","For auth-gated routes, return a redirect (302) instead of 401/403, or skip prerendering them.","Reproduce locally with `pnpm build && pnpm prerender` (or the project's prerender script) and inspect the entry.server.tsx output."],"exampleFix":"// app/routes/protected.tsx — before\nexport async function loader({ request }) {\n  const user = await getUser(request); // throws 500 during prerender (no request session)\n  return { user };\n}\n// after — skip work during prerender\nexport async function loader({ request }) {\n  if (import.meta.env.REACT_ROUTER_PRERENDER) return json({ user: null });\n  const user = await getUser(request);\n  return { user };\n}","handlingStrategy":"try-catch","validationCode":"// before prerendering, dry-run each path against entry.server in dev\nfor (const path of prerenderPaths) {\n  const res = await fetch(new URL(path, devOrigin));\n  if (![200,202,301,302,303,307,308].includes(res.status) && !(path === '/__spa-fallback.html' && res.status === 404)) {\n    console.warn(`Path ${path} will fail prerender with status ${res.status}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try { await prerenderPath(path); }\ncatch (e) {\n  if (e instanceof Error && e.message.startsWith('Prerender (data):')) {\n    const body = await (e.cause as Response | undefined)?.text();\n    console.error('Server error body:', body);\n  }\n  throw e;\n}","preventionTips":["Make loaders prerender-safe: guard runtime-only calls behind import.meta.env flags.","Return redirects instead of 401/403 for auth-gated routes during prerender.","Smoke-test prerender paths in dev before adding them to the prerender config."],"tags":["prerender","rsc","ssr","entry-server","status-code"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}