withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
43.84k stars 2.28k forks source link

fix(routing): return correct status code for `500.astro` and `404.astro` #11308

Closed ematipico closed 4 days ago

ematipico commented 1 week ago

Changes

Closes https://github.com/withastro/astro/issues/11306

This PR hardcodes the status code of the rendered pages 404.astro and 500.astro.

This issue was never evident because users were never able to see/catch the response emitted by these custom pages, but with the rewriting this was evident.

I updated the renderPage function to set a different status in case we attempt to render these particular routes.

Testing

Testing here is particularly difficult, because we are inside a rewriting cycle.

I locally tested that in const response = await next() the response holds a 404 or a 500 depending on where we're redirecting.

Docs

N/A

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: ce9b35b82336838cd7620732ecd222a9647b5558

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