refactor(client-side): update story check middleware
if fetching a story returns an error, check that the error code is 403 (forbidden) as well before redirecting
This commit is contained in:
parent
80dbd05468
commit
e6ba48dc2f
@ -14,7 +14,7 @@ export const storyMiddleware = defineNuxtRouteMiddleware(async (to, from) => {
|
||||
console.log("to n from", to, from, data);
|
||||
const { data: story, error } = await useApiFetch<SingleChapterResult>(to.path);
|
||||
if (error.value) {
|
||||
if (error.value.message.toLocaleLowerCase() == "unauthenticated") {
|
||||
if (error.value.message.toLocaleLowerCase() == "unauthenticated" || error.value.statusCode == "403") {
|
||||
return navigateTo("/auth/login");
|
||||
}
|
||||
return showError(error.value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user