You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above is extracted from the generated code (_workers.js/chunks/_@astrojs-ssr-adapter_<hash>.mjs). As the 404 page is server-side rendered, there is no 404.html generated. Hence, Cloudflare Pages assumes the app is a SPA and rewriting all paths to index.html. This leads to an issue that asset.status is 200 instead of 400 and the asset is index.html.
Personally, I think one way to solve this is for the adapter to generate an empty 404.html (possibly configurable by an option in astro.config.mjs? e.g. generate404/ isSPA etc). env.ASSETS.fetch will return 404 when it sees a 404.html and Astro will render the 404.astro.
What you observe is the expected behavior. If Cloudflare doesn't see an static 404.html, it expects SPA mode, and behaves like your described. So far so good. Now the question is how to handle this. One way is to tell users to set prerender = true, the other is to inject an empty page, which could also be a bit unexpected for some. Not sure what the best solution is here. I'll ask the team in Discord :)
Astro Info
Describe the Bug
Situation
Setting
const prerender = false
on the 404 page; other pages are statically generated.Reproducing:
wrangler pages dev ./dist
Result
The 404 page is not rendered, instead, the index page is rendered.
Possible cause
The above is extracted from the generated code (
_workers.js/chunks/_@astrojs-ssr-adapter_<hash>.mjs
). As the 404 page is server-side rendered, there is no 404.html generated. Hence, Cloudflare Pages assumes the app is a SPA and rewriting all paths to index.html. This leads to an issue thatasset.status
is200
instead of400
and the asset is index.html.Workaround
What's the expected result?
The 404 page should be rendered.
Link to Minimal Reproducible Example
https://codesandbox.io/p/devbox/sfgjcf
Participation
The text was updated successfully, but these errors were encountered: