-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Endpoint Response.redirect header modification #9871
Labels
Comments
florian-lefebvre
added
- P3: minor bug
An edge case that only affects very specific usage (priority)
regression
and removed
needs triage
Issue needs to be triaged
labels
Jan 29, 2024
Thanks for looking into it, this is all spot on! I didn't know Response.redirect would have immutable headers, but it would make sense. The directive would have to be something other than a header. |
I have written a test based on your repro here: main...lilnasy:astro:fix/9871 Feel free to take that and attempt a fix. I would guess putting the |
friedemannsommer
added a commit
to friedemannsommer/astro
that referenced
this issue
Jan 30, 2024
lilnasy
pushed a commit
that referenced
this issue
Jan 30, 2024
* add test * added runtime endpoint test for `new Response` * added `try..catch` for reroute directive handling Fixes #9871 * added changeset * replaced `try..catch` with HTTP status code check based on the suggestion of @lilnasy * updated changeset description * added more tests for the endpoint reroute header * fixed grammar in `renderEndpoint` comment * updated endpoint tests to check for the reroute directive header in lower-case * updated changeset description
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When returning
Response.redirect
from an endpoint, therenderEndpoint
function tries to set an HTTP response header on theResponse
object of thehandler
. This will throw aTypeError: immutable
and return an HTTP 500 error to the client.Note that
new Response(..)
andResponse.json
are not affected by this issue, even though they technically should be 🤔.This is a relatively new change introduced by
075706f26d2e11e66ef8b52288d07e3c0fa97eb1
.These changes are included in Astro from version
4.2.4
and later.What's the expected result?
The client should receive a HTTP 30X response with a
Location
header.Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-2fktbw?file=README.md
Participation
The text was updated successfully, but these errors were encountered: