Skip to content

Commit a4a2342

Browse files
committed
fix(Plugin): check the route path before redirecting
1 parent c4b6e06 commit a4a2342

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plugins/axios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import qs from 'qs'
22
import {Plugin} from '@nuxt/types'
33

4-
const axios: Plugin = ({$axios, redirect, $auth}) => {
4+
const axios: Plugin = ({$axios, redirect, $auth, route}) => {
55

66
// Set array format to repeat
77
$axios.onRequest(config => {
@@ -16,10 +16,11 @@ const axios: Plugin = ({$axios, redirect, $auth}) => {
1616
return response
1717
},
1818
async (error) => {
19-
if (error.response.status === 401) {
19+
if (error.response.status === 401 && route.path !== '/login') {
2020
if($auth.loggedIn) {
2121
await $auth.logout();
2222
}
23+
2324
redirect(401, "/login");
2425
} else {
2526
return Promise.reject(error);

0 commit comments

Comments
 (0)