Skip to content

Commit

Permalink
fix: fix wrong history when using client side loader redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Repraance authored Oct 13, 2023
1 parent 8d14c6a commit 177742b
Show file tree
Hide file tree
Showing 10 changed files with 1,033 additions and 41 deletions.
5 changes: 1 addition & 4 deletions packages/platform-web/src/shuvi-app/app/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ export const createApp: CreateAppClient = ({
if (isThirdSite(location)) {
window.location.replace(location);
} else {
next({
path: location,
replace: true
});
next(location);
}
runLoadersTrace.setAttribute(
SHUVI_CLIENT_RUN_LOADERS.attrs.errorType.name,
Expand Down
2 changes: 2 additions & 0 deletions packages/platform-web/src/shuvi-app/app/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const createApp: CreateAppServer = options => {
if (isRedirect(error)) {
const location = error.headers.get('Location')!;
const status = error.status;
// server side redirect is different from regular route redirect because it has the extra data - statusCode
// So it won't change route target, but just store the redirect location in state
next({
path: pathToString(to),
replace: true,
Expand Down
Loading

0 comments on commit 177742b

Please sign in to comment.