{"record":{"id":"978637aa8f527ea3","repo":"remix-run/react-router","slug":"prerender-resource-received-a-response-status","errorCode":null,"errorMessage":"Prerender (resource): Received a ${response.status} status code from `entry.server.tsx` while prerendering the `${pathname}` path.\\n${new TextDecoder().decode(contents)}","messagePattern":"Prerender \\(resource\\): 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":2585,"sourceCode":"                path: pathname,\n                contents: data,\n              },\n            ],\n            // After saving the .data file, request the HTML page.\n            // The data is passed along to be embedded in the response header.\n            requests: !metadata.isResourceRoute\n              ? [createRouteRequest(metadata.path, ctx.reactRouterConfig, data)]\n              : [],\n          };\n        }\n\n        // Handle resource route responses\n        if (metadata.type === \"resource\") {\n          let pathname = new URL(request.url).pathname;\n          let contents = new Uint8Array(await response.arrayBuffer());\n\n          if (response.status !== 200) {\n            throw new Error(\n              `Prerender (resource): Received a ${response.status} status code from ` +\n                `\\`entry.server.tsx\\` while prerendering the \\`${pathname}\\` ` +\n                `path.\\n${new TextDecoder().decode(contents)}`,\n            );\n          }\n\n          return [\n            {\n              path: pathname,\n              contents,\n            },\n          ];\n        }\n\n        // Handle document responses (html or spa)\n        let html = await response.text();\n\n        if (metadata.type === \"spa\") {","sourceCodeStart":2567,"sourceCodeEnd":2603,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/plugin.ts#L2567-L2603","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: resource route 500s during prerender\nexport const loader = async () => {\n  const data = await db.query(); // throws if DB down\n  return json(data);\n};\n// after: return a deterministic fallback at build time\nexport const loader = async ({ request }) => {\n  if (import.meta.env.PROD && !process.env.DATABASE_URL) {\n    return json(CACHED_FEED);\n  }\n  return json(await db.query());\n};","handlingStrategy":"validation","validationCode":"const assertResourceOk = (status: number, path: string) => {\n  if (status !== 200) throw new Error(`Resource ${path} returned ${status}`);\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["prerender","resource-route","loader","entry-server","build"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}