fix(nuxt): return RenderResponse
for redirects
#20496
Merged
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.
π Linked issue
#20244 (comment)
resolves #20294
resolves #20432
β Type of change
π Description
This adds an internal way for Nuxt composables to predetermine the type of response from the render handler, rather than directly interacting with
event.node.res
. It then updatesnavigateTo
handling to use this internal._renderResponse
property for indicating status code, etc. There is space here for improving this, including maybe using h3'ssendRedirect
method behind the scenes in nitro so we don't have to generate the HTML body, for example.The hook
app:redirected
was also only added for the purpose of setting cookies before immediately returning a response. But nowapp:rendered
is just as good a response, and we might consider deprecatingapp:redirected
in favour ofapp:rendered
. Thoughts welcome.Finally, we resolve an issue with setup functions loading even after a redirect by switching from
beforeEach
toafterEach
, and add a test fixture.π Checklist