You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`import { NuxtAuthHandler } from '#auth'
import AzureADProvider from 'next-auth/providers/azure-ad'
export default NuxtAuthHandler({
pages: {
// Change the default behavior to use /login as the path for the sign-in page
signIn: '/login',
},
secret: process.env.AUTH_SECRET,
providers: [
// @ts-expect-error You need to use .default here for it to work during SSR. May be fixed via Vite at some point
AzureADProvider.default({
clientId: process.env.AZURE_AD_CLIENT_ID,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AZURE_AD_TENANT_ID,
}),
],
const user = data.value?.user
if (!user?.email && route.path.includes('/')) {
return navigateTo('/login')
}
})
`
Describe the bug
nitro] [dev] [unhandledRejection] Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client [next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error checks.state argument is missing { error: TypeError: checks.state argument is missing at Client.callback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\openid-client\lib\client.js:387:13) at oAuthCallback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\lib\oauth\callback.js:127:29) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.callback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\routes\callback.js:52:11) at async AuthHandler (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\index.js:201:28) at async file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/chunks/node-server.mjs:430:24 at async Object.handler (file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/node_modules/h3/dist/index.mjs:840:19) at async Server.toNodeHandle (file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/node_modules/h3/dist/index.mjs:915:7) { name: 'OAuthCallbackError', code: undefined }, providerId: 'azure-ad', message: 'checks.state argument is missing' }
Additional context
I'm using a custom middleware, if i remove the custom middleware i get a headers don't exist error.
I used github before, and that worked with the same setup
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
- Operating System:
Windows_NT`v16.19.0
3.1.1
2.1.1
pnpm@8.3.1
vite
routeRules
,nitro
,css
,modules
,auth
,unocss
,app
@unocss/nuxt@0.49.2
,@pinia/nuxt@0.4.6
,@vueuse/nuxt@9.13.0
,@sidebase/nuxt-auth@0.6.0-beta.2
,nuxt-icon@0.3.2
Reproduction
My server/api/auth/[...].ts
`import { NuxtAuthHandler } from '#auth'
import AzureADProvider from 'next-auth/providers/azure-ad'
export default NuxtAuthHandler({
pages: {
// Change the default behavior to use
/login
as the path for the sign-in pagesignIn: '/login',
},
secret: process.env.AUTH_SECRET,
})
`
nuxt.config.ts
auth: { baseURL: '/api/auth', globalAppMiddleware: { isEnabled: false, }, isEnabled: true, provider: { type: 'authjs', defaultProvider: 'azure-ad', trustHost: true, }, },
middleware/auth.ts
`export default defineNuxtRouteMiddleware(async (route) => {
const { data } = useAuth()
})
`
Describe the bug
nitro] [dev] [unhandledRejection] Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client [next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error checks.state argument is missing { error: TypeError: checks.state argument is missing at Client.callback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\openid-client\lib\client.js:387:13) at oAuthCallback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\lib\oauth\callback.js:127:29) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.callback (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\routes\callback.js:52:11) at async AuthHandler (C:\Users\m.teekens\sandb\validation\cash-statement\.output\server\node_modules\next-auth\core\index.js:201:28) at async file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/chunks/node-server.mjs:430:24 at async Object.handler (file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/node_modules/h3/dist/index.mjs:840:19) at async Server.toNodeHandle (file:///C:/Users/m.teekens/sandb/validation/cash-statement/.output/server/node_modules/h3/dist/index.mjs:915:7) { name: 'OAuthCallbackError', code: undefined }, providerId: 'azure-ad', message: 'checks.state argument is missing' }
Additional context
I'm using a custom middleware, if i remove the custom middleware i get a headers don't exist error.
I used github before, and that worked with the same setup
Logs
No response
The text was updated successfully, but these errors were encountered: