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(rewrite): correctly update the status code during a rewrite #11352

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

ematipico
Copy link
Member

Changes

Closes #11306

The issue was caused by this.status inside the RenderContext class. This status code is then passed to the SSResult and used as initial status of Response.

This status code was passed by route.ts. It was a 404 because /foo didn't match any route, however we still call the middleware because the user chose routing: 'manual'.

When we arrived to the middleware, we executed the rewrite, and we need update this status code in case we find a RouteData and a ComponentInstance.

I moved the shared logic inside a new, private, function called #executeRewrite as per @florian-lefebvre suggestion.

Testing

Added a new test case

Docs

N/A

Copy link

changeset-bot bot commented Jun 26, 2024

🦋 Changeset detected

Latest commit: d97cdbf

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 Jun 26, 2024
@ematipico ematipico merged commit a55ee02 into main Jul 1, 2024
5 checks passed
@ematipico ematipico deleted the fix/change-rewrite-status-code branch July 1, 2024 13:55
@astrobot-houston astrobot-houston mentioned this pull request Jul 1, 2024
ematipico added a commit that referenced this pull request Jul 18, 2024
* fix(rewrite): correctly update the status code during a rewrite

* rebase

* remove `.only`

* remove log
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.

Rewriting doesn't use HTTP status code from rewritten response
2 participants