Skip to content
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

Fix prerendered 404 page handling in SSR #6558

Merged
merged 2 commits into from
Mar 16, 2023
Merged

Fix prerendered 404 page handling in SSR #6558

merged 2 commits into from
Mar 16, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 15, 2023

Changes

Fix #6511

When falling back to 404.astro, and that 404.astro is prerendered, skip rendering it in SSR to prevent runtime errors. Instead, respond with a code 404 so that the environment can fallback and use the prerendered 404.html.

Testing

I've added a test to capture the first part. But I've not confirmed if environments do fallback to the 404.html if we return a 404 status code.

But in a way, if a person opt to prerendering 404.html, it probably means that the deployed environment supports falling back to it.

Docs

Perhaps we can document which environments support falling back to 404.html. It might be good to get the community to fill in this information as I find it rarely documented (especially paired with functions/workers), so it needs some trial and error.

@changeset-bot
Copy link

changeset-bot bot commented Mar 15, 2023

🦋 Changeset detected

Latest commit: 3033779

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 15, 2023
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bluwy bluwy merged commit 6c465e9 into main Mar 16, 2023
@bluwy bluwy deleted the fix-prerender-404 branch March 16, 2023 15:03
@astrobot-houston astrobot-houston mentioned this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get 500 error with a prerender 404 page and cloudflare SSR
2 participants