{"record":{"id":"2952d31bfa2c4a27","repo":"remix-run/react-router","slug":"prerender-html-received-a-response-status-st","errorCode":null,"errorMessage":"Prerender (html): Received a ${response.status} status code from `entry.server.tsx` while prerendering the `${pathname}` path.\\n${html}","messagePattern":"Prerender \\(html\\): 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/plugin.ts","lineNumber":2659,"sourceCode":"          // A short delay causes Google to interpret the redirect as temporary.\n          // https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh\n          let delay = response.status === 302 ? 2 : 0;\n          let escapedLocation = escapeHtml(location ?? \"\");\n          let escapedPathname = escapeHtml(pathname);\n          html = `<!doctype html>\n<head>\n<title>Redirecting to: ${escapedLocation}</title>\n<meta http-equiv=\"refresh\" content=\"${delay};url=${escapedLocation}\">\n<meta name=\"robots\" content=\"noindex\">\n</head>\n<body>\n\t<a href=\"${escapedLocation}\">\n    Redirecting from <code>${escapedPathname}</code> to <code>${escapedLocation}</code>\n  </a>\n</body>\n</html>`;\n        } else if (response.status !== 200) {\n          throw new Error(\n            `Prerender (html): Received a ${response.status} status code from ` +\n              `\\`entry.server.tsx\\` while prerendering the \\`${pathname}\\` ` +\n              `path.\\n${html}`,\n          );\n        }\n\n        return [\n          {\n            path: `${pathname}/index.html`,\n            contents: html,\n          },\n        ];\n      },\n      logFile(outputPath, metadata) {\n        invariant(viteConfig);\n        invariant(metadata);\n        // SPA fallback logging is handled in finalize after we know the final filename\n        if (metadata.type === \"spa\") {","sourceCodeStart":2641,"sourceCodeEnd":2677,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/plugin.ts#L2641-L2677","documentation":"Thrown in `postProcess` for standard HTML document renders (after redirect handling). When the response status is not 200 (and not a 3xx redirect handled earlier), the prerendered HTML would be an error page committed to disk, so React Router aborts the build. The full HTML is included for diagnosis.","triggerScenarios":"A document route's loader throws (resulting in a 500 from `entry.server.tsx`); the route's render errors during SSR for a `prerender`-listed path; `entry.server.tsx` returns a non-200 `Response` (other than the redirect case already handled).","commonSituations":"Prerendering a static page whose loader throws on a missing CMS value; an error boundary renders a custom 500 page during SSR for the prerendered route; CI build with an env var unset causing SSR to fail.","solutions":["Visit the path in preview/serve to read the actual SSR error in the terminal log.","Make the loader and render path deterministic at build time (no thrown errors for the prerendered URL).","Remove the path from `prerender` if it legitimately cannot render statically.","Check `entry.server.tsx` for unconditional non-200 responses."],"exampleFix":"// before: loader throws for a prerendered page\nexport const loader = () => { throw new Response(null, { status: 500 }); };\n// after\nexport const loader = () => json({ ok: true });","handlingStrategy":"validation","validationCode":"const assertDocOk = (status: number, path: string) => {\n  if (status !== 200) throw new Error(`Document ${path} returned ${status}`);\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document routes listed in `prerender` must render successfully (200) at build time.","Don't let loaders or renderers throw for prerendered paths.","Inspect `entry.server.tsx` for unconditional non-200 responses."],"tags":["prerender","html","entry-server","loader","build"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}