-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server-rendered 404 pages no longer work on Cloudflare #67
Comments
Thanks for the thorough details and sorry for the frustration! We're tracking down quite a few 404 related issues (withastro/astro#8070) and hoping to fix them soon. The original changes probably shouldn't have gone out in a patch release. |
This might be the same / related to issue withastro/astro#8054 |
The issues described here are trickier, unfortunately. |
I'm having the same issue, I'll add more context maybe it can help. In my case, I'm using ---
const lang = Astro.request.headers.get('Accept-Language')
if (lang.startsWith('it')) return Astro.redirect('/it')
return Astro.redirect('/en')
--- On local dev, both work as expected. Once deployed, If try to access a non-existent page the cloudflare server returns a 500 errror. The index page logic works as expected instead. |
Can we confirm that this is still an issue. I do have projects deployed with |
Closing for now, because the Issue seems to be stale. Happy to reopen, if we get new information or confirmation. |
Sorry, the last replies were sent to my spam. |
Thanks for your effort, ToxiWoxi! |
Ok just to clear some things about this issue. We need to different where the fallback routing for a 404 page happens.
|
@lilnasy this was the PR which moved the logic from the adapter to Astro. Not sure if that matches the time range, aligning with the versions in this report. https://github.com/withastro/astro/pull/4018/files |
404/500 logic was refactored in this pr. This aligns with when the behavior was changed. |
You are right these two PRs are where 404/500 behavior changed.
Yep, and I'm pretty sure it is astro in this case. It would be happening somewhere around these parts. |
The returning
|
This comment was marked as outdated.
This comment was marked as outdated.
@lilnasy yeah that is correct. I was able to debug the change in |
@alexanderniebuhr after the changes in 2.9.7 (the prs mentioned above), SSR 404 pages stopped returning anything. The adapter was not updated until after Astro 2.10.5. You can use the astro@2.10.5-cloudflare@6.6.2 and astro@2.10.5-cloudflare@6.7.0 branches to compare the changes with the adapter. |
So the change is that the new
That means that for There are currently two workarounds to this:
Both of those workarounds should give you the "known" behavior back of getting a 404 with no content. That issue however is probably an Astro topic. @lilnasy do you think we should transfer this issue back to the main repo, and create another issue for the |
Yeah, that makes sense. |
This is only relevant for the adapter, and I commented it on that issue, just cross-posting here for visibility: https://discord.com/channels/595317990191398933/1174021841023664288 |
It turns out that this was in fact an adapter issue. If this could be moved back, that'd be great. Otherwise, there is a pending pull request in the adapters repo that will close it if merged. |
I guess not, technically.
The pr solves issue 2. My understanding is that issue 1 appears to be caused by #64, so I think this issue is now technically about issue 2. I can edit the original comment on this issue and make changes to the test repo I have to reflect this later if we agree on that so there is no further confusion. (I will be out of the house for the next 2 hours) |
After looking at the PR, I see what you mean. The adapter did not give astro's SSR functions the opportunity to render |
I don't think this is true, and only one of the issues can be fixed in the adapter. |
Both issues are technically adapter, though you are correct that only one can be fixed. The issues with the exclude routing strategy are an adapter issue. #66 solves it. The issues with the include routing strategy seems to be that Cloudflare treats apps without |
I'm still not convinced, I know that the adapter code returns an empty 404 response, however
We are, we need to change the way we generate |
I still think this is a Astro issue. Unless the following change in behavior is known and expected, but I don't think so nor do I have confirmation:
|
What version of
astro
are you using?2.9.7 to 3.3.2
Are you using an SSR adapter? If so, which one?
Cloudflare
What package manager are you using?
npm
What operating system are you using?
Linux & Deployment
What browser are you using?
Chrome
Describe the Bug
Issue: Changes to 404 handling have resulted in server-rendered 404 pages no longer working on Cloudflare.
Behaviors in different versions
Expected behavior:
/eXaMPLe
can be redirected to/example
/index
can be redirected to/
Updated behavior with Astro v2.9.7 and higher
Updated behavior with Cloudflare adapter v6.7.0 and higher
This issue does not happen on latest when prerendering the 404 page
However, this doesn't allow you to use the 404 page to do case-corrections and handle aliases
latest-prerendered
deployment in my provided example dedicated to this behaviorDeployments and their issues
404.astro
index.astro
index.astro
404.astro
What's the expected result?
/eXaMPLe
can be redirected to/example
/index
can be redirected to/
Link to Minimal Reproducible Example
https://github.com/ToxiWoxi/astro-404-issue
Participation
The text was updated successfully, but these errors were encountered: