瀏覽代碼

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

Olivier Massot 6 月之前
父節點
當前提交
a415b3505f
共有 1 個文件被更改,包括 11 次插入2 次删除
  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
   }