{"record":{"id":"49cb4626e162a461","repo":"sveltejs/kit","slug":"could-not-create-a-fallback-page","errorCode":null,"errorMessage":"Could not create a fallback page","messagePattern":"Could not create a fallback page","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/postbuild/fallback.js","lineNumber":52,"sourceCode":"\n\tconst response = await server.respond(new Request(origin + '/[fallback]'), {\n\t\tgetClientAddress: () => {\n\t\t\tthrow new Error('Cannot read clientAddress during prerendering');\n\t\t},\n\t\tprerendering: {\n\t\t\tfallback: true,\n\t\t\tdependencies: new Map(),\n\t\t\tremote_responses: new Map(),\n\t\t\tresolved_route_ids: new Set()\n\t\t},\n\t\tread: (file) => readFileSync(join(assets, file))\n\t});\n\n\tif (response.ok) {\n\t\treturn await response.text();\n\t}\n\n\tthrow stackless('Could not create a fallback page');\n}\n","sourceCodeStart":34,"sourceCodeEnd":54,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/postbuild/fallback.js#L34-L54","documentation":"With adapter-static's `fallback` option, SvelteKit builds a SPA fallback page by booting the built server in a subprocess and requesting the synthetic route /[fallback]. If the response is not ok, generate_fallback throws this stackless error. Typical causes are server-side errors during the fallback render (load failures, missing routes, bad env).","triggerScenarios":"Running `vite build` with adapter-static fallback configured and the internal server.respond for origin + '/[fallback]' returns a non-ok status (e.g. 500 from a load function throwing, missing prerendered dependencies, invalid manifest/env).","commonSituations":"+layout.server.js or root load throws for the fallback route; env vars required by load functions absent at build time; adapter-static fallback set but app has server-only endpoints erroring; misconfigured origin or assets paths.","solutions":["Look for the server error logged before this message (the fallback render usually prints the real 500 cause)","Ensure load functions tolerate the synthetic /[fallback] route and don't throw (guard on route.id or use fallback-safe code)","Pass the required env variables to the build so server.init({ env }) succeeds","Set `strict: false` / provide `fallback: 'index.html'`-style static fallback instead of dynamic generation if the app is purely client-rendered"],"exampleFix":"// before (+layout.server.js)\nexport async function load({ params }) {\n  return { page: await getPage(params.slug) }; // throws for /undefined-slug fallback\n}\n\n// after\nexport async function load({ params }) {\n  const page = await getPage(params.slug).catch(() => null);\n  return { page };\n}","handlingStrategy":"try-catch","validationCode":"// verify the fallback route renders before full build\nconst res = await server.respond(new Request(origin + '/[fallback]'), { prerendering: { fallback: true } });\nif (!res.ok) throw new Error(`fallback render returned ${res.status}`);","typeGuard":null,"tryCatchPattern":"try {\n  const html = await generateFallback(opts);\n} catch (e) {\n  console.error('Fallback generation failed; check server error above');\n  throw e;\n}","preventionTips":["Make load functions resilient for the synthetic /[fallback] route","Provide required env vars at build time","Verify adapter-static fallback config and origin settings","Log and handle errors in the root layout load"],"tags":["prerender","adapter-static","spa","build"],"backgroundTag":"spa-fallback-generation-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}