fix 404: dynamic 404.astro route to render "not found" page #180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Updating
@astrojs/cloudflare
tov10
in #154 appears to have broken Cloudflare's built-in behaviour to return the closest404.html
in case a page is not found.This PR solves this issue by replacing Cloudflare's behaviour with Astro's Custom 404 Page Behaviour using a dynamic
src/pages/404.astro
(prerender = false
) so that it has access to the request object and can match the locale during runtime.Associated issue
Resolves #161
Resolves #135
How to test
Test different pages that don't exist and see that it returns the Not Found page with the closest locale and with a 404 status:
/nl/aapje → Niet gevonden (404)
/en/aapje → Not Found (404)
/de/aapje → Not Found (404)
/aapje → Not Found (404)
Checklist
I have added a decision log entry if the change affects the architecture or changes a significant technology