fix: stop redirecting to login on /login
This commit is contained in:
@@ -33,13 +33,16 @@ const createErrorLink = (callback: CreateLinkOptions['onError']): ApolloLink =>
|
|||||||
callback?.(message);
|
callback?.(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.error(
|
||||||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (message === NOT_AUTHORISED) {
|
if (message === NOT_AUTHORISED) {
|
||||||
setItem('token', '');
|
setItem('token', '');
|
||||||
window.location.href = URLS.LOGIN;
|
|
||||||
|
if (window.location.pathname !== URLS.LOGIN) {
|
||||||
|
window.location.href = URLS.LOGIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,12 +50,13 @@ const createErrorLink = (callback: CreateLinkOptions['onError']): ApolloLink =>
|
|||||||
if (autoSnackbar) {
|
if (autoSnackbar) {
|
||||||
callback?.(networkError.toString());
|
callback?.(networkError.toString());
|
||||||
}
|
}
|
||||||
console.log(`[Network error]: ${networkError}`);
|
|
||||||
|
console.error(`[Network error]: ${networkError}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
const noop = () => {};
|
const noop = () => { };
|
||||||
|
|
||||||
const createLink = (options: CreateLinkOptions): ApolloLink => {
|
const createLink = (options: CreateLinkOptions): ApolloLink => {
|
||||||
const { uri, onError = noop, token } = options;
|
const { uri, onError = noop, token } = options;
|
||||||
|
Reference in New Issue
Block a user