fix: follow server redirects in client navigation #605
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.
Closes #601
initClient({ spaMode: true })
onNavigate
to be a promiseI dug into this without seeing #603 😅. But if I understand correctly, my approach is different and as a result, client side rendering remains possible across same origin redirects.
I also figured that given cross-origin server redirects are acceptable with server navigation, it would make sense to gracefully fall back to server redirects when we encounter them. This is now done by catching the CORS error and falling back to browser navigation.
Unfortunately there's no way to see the location of a cross origin redirect in a fetch response, so the check is for a generic
TypeError: Failed to fetch
. However the fallback behavior is simply to reload the window at the originally requested url on the site's origin, so I don't see this being an issue.This is working nicely from my perspective as a dev user. But if this doesn't make sense as a contribution I'm happy to make changes.
CleanShot.2025-07-16.at.21.17.24.mp4