Skip to content

Commit

Permalink
fix: Fix error not redirect to login when refresh token failed
Browse files Browse the repository at this point in the history
  • Loading branch information
trandaison committed Apr 10, 2024
1 parent 39213e1 commit 64ab35d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/runtime/services/HttpService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { $Fetch, FetchContext } from "ofetch";
import { navigateTo, useNuxtApp, useRoute, useRouter } from "#imports";
import { useLocalizeRoute } from "#build/useLocalizeRoute.mjs";
import { middleTruncate, HTTP_STATUS_UNAUTHORIZED, AuthStatus } from "../utils";
import type { AuthConfig, AuthService } from "../../types";

Expand All @@ -8,6 +9,7 @@ export default class HttpService {
private nuxtApp;
private route;
private router;
private loginRoute;

constructor(
$fetch: $Fetch,
Expand All @@ -17,6 +19,8 @@ export default class HttpService {
this.nuxtApp = useNuxtApp();
this.route = useRoute();
this.router = useRouter();
const { localeRoute } = useLocalizeRoute();
this.loginRoute = localeRoute({ name: this.$configs.routes.login.name });
this.setup($fetch);
}

Expand Down Expand Up @@ -148,7 +152,7 @@ export default class HttpService {
this.$auth.setReferer(referer);
}
const loginPath = this.router.resolve({
name: this.$configs.routes.login.name,
name: this.loginRoute.name!,
query: { status },
});
return this.nuxtApp.runWithContext(() => navigateTo(loginPath));
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "./playground/.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json"
}

0 comments on commit 64ab35d

Please sign in to comment.