-
Notifications
You must be signed in to change notification settings - Fork 324
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 RSC Redirects #965
Fix RSC Redirects #965
Conversation
05fa230
to
2e05650
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This is way more elegant than I assumed it would be.
packages/hydrogen/src/framework/Hydration/ServerComponentResponse.server.ts
Show resolved
Hide resolved
@mcvinci FYI there's some documentation changes in here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs changes look good! Thanks, @blittle!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Bret! Very simple and elegant solution.
I've noticed there are two Redirect.client.xyz.js
files emitted when building the client, and it seems to be related to including Redirect component in ServerComponentResponse.server.js
. I've no idea why because that file should not affect the client at all...
I think it is not a big issue anyway so we can merge this. Perhaps things will be clearer once we extract client stuff into hydrogen-ui
.
|
||
useEffect(() => { | ||
if (to.startsWith('http')) { | ||
window.location.href = to; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be window.location.replace
instead so its truly a redirect?
Description
Fix RSC Redirects. Resolves #947
Additional context
Fix server redirects to work properly with RSC responses. For example, the redirect component within the starter template changes:
This server component is executed two ways:
response.redirect(...)
returns a component which will redirect on the client.The redirect e2e test has been modified to cover this scenario.