sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.31k stars 164 forks source link

When `useAuth` is called in middleware, Nuxt throws a 500 error #794

Closed TheDutchCoder closed 4 months ago

TheDutchCoder commented 4 months ago

Environment


Reproduction

Your reproduction links don't include nuxt-auth, you should fix that first

Describe the bug

When defining middleware (wether in a separate file or inline), the nuxt sidebase module throws Nuxt internal errors:

at useNuxtApp (./node_modules/nuxt/dist/app/nuxt.js:249:13)
at Module.useRuntimeConfig (./node_modules/nuxt/dist/app/nuxt.js:259:10)
at Module.formatToken (./node_modules/@sidebase/nuxt-auth/dist/runtime/utils/local.mjs:6:84)
at ./node_modules/@sidebase/nuxt-auth/dist/runtime/composables/local/useAuthState.mjs:31:76
at ReactiveEffect.fn (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:994:13)
at ReactiveEffect.run (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:181:19)
at get value (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:1006:109)
at Reflect.get ()
at ReadonlyReactiveHandler.get (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:482:25)
at Object.onRequest (./src/plugins/ofetch.ts:58:39)

Additional context

No response

Logs

No response

TheDutchCoder commented 4 months ago

I can't repro this on a clean install, so I'm assuming the errors actually originates somewhere else.