Browse Source

do not redirect to logout on error if not in production env

Olivier Massot 6 tháng trước cách đây
mục cha
commit
a415b3505f
1 tập tin đã thay đổi với 11 bổ sung2 xóa
  1. 11 2
      plugins/init.server.ts

+ 11 - 2
plugins/init.server.ts

@@ -9,6 +9,7 @@ export default defineNuxtPlugin(async () => {
     return
   }
 
+  const runtimeConfig = useRuntimeConfig()
   const { redirectToLogout } = useRedirect()
 
   const bearer: CookieRef<string | null> = useCookie('BEARER') ?? null
@@ -17,13 +18,21 @@ export default defineNuxtPlugin(async () => {
     useCookie('SwitchAccessId') ?? null
 
   if (accessCookieId.value === null || Number.isNaN(accessCookieId.value)) {
-    redirectToLogout()
+    if (runtimeConfig.public.env === 'production') {
+      redirectToLogout()
+    } else {
+      console.error('Missing access id')
+    }
     return
   }
 
   const accessId: number = parseInt(accessCookieId.value)
   if (isNaN(accessId)) {
-    redirectToLogout()
+    if (runtimeConfig.public.env === 'production') {
+      redirectToLogout()
+    } else {
+      console.error('Invalid access id')
+    }
     return
   }