This repository was archived by the owner on Feb 10, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
Server-rendered 404 pages no longer work on Cloudflare #67
Copy link
Copy link
Closed
Labels
- P2: has workaroundBug, but has workaround (priority)Bug, but has workaround (priority)pkg: cloudflare
Description
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:
- The 404 page loads when going to a non-existent route
- The 404 page can perform redirects to case-corrected versions of pages or aliases will redirect to correct page
- Examples:
/eXaMPLecan be redirected to/example/indexcan be redirected to/
- Examples:
- These behaviours are tested to work in Astro v2.9.6 with Cloudflare adapter v6.6.2
Updated behavior with Astro v2.9.7 and higher
- Cloudflare sends a default 404 error with no page when accessing a non-existent route
- The 404 page still can be accessed from /404
- Case-corrections and aliases will not be redirected
- These behaviours are tested to work in Astro v2.9.7 and higher with Cloudflare adapter v6.6.2
Updated behavior with Cloudflare adapter v6.7.0 and higher
- Cloudflare returns with the contents of the index route without redirecting or updating the url when accessing a non-existent route
- The 404 page still can be accessed from /404
- Case-corrections and aliases still will not be redirected
- These behaviours are tested to work in Astro v2.10.5 and higher with Cloudflare adapter v6.7.0 and higher and is the current behavior on latest versions of both.
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
- The
latest-prerendereddeployment in my provided example dedicated to this behavior
Deployments and their issues
| Deployment | Bad Routes | Aliases | Case-correction |
|---|---|---|---|
| astro@2.9.6 | Returns 404.astro |
Working | Working |
| astro@2.9.7 | Returns nothing | Configured redirects only | Not working |
| astro@2.10.5-cloudflare@6.6.2 | Returns nothing | Configured redirects only | Not working |
| astro@2.10.5-cloudflare@6.7.0 | Returns index.astro |
Configured redirects only | Not working |
| latest | Returns index.astro |
Configured redirects only | Not working |
| latest-prerendered | Renders 404.astro |
Configured redirects only | Not working |
What's the expected result?
- The 404 page loads when going to a non-existent route
- The 404 page can perform redirects to case-corrected versions of pages or aliases will redirect to correct page
- Examples:
/eXaMPLecan be redirected to/example/indexcan be redirected to/
- Examples:
- These behaviours are tested to work in Astro v2.9.6 with Cloudflare adapter v6.6.2
Link to Minimal Reproducible Example
https://github.com/ToxiWoxi/astro-404-issue
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: has workaroundBug, but has workaround (priority)Bug, but has workaround (priority)pkg: cloudflare