当我在 Safari 上使用 PWA 设置运行它时,我的 Next-Auth 应用程序似乎在生产模式下失败。
它让我Error: Invalid state returned from oAuth provider
。
附注:
使用的配置
const options = {
providers: [
Providers.Google({
clientId: process.env.NEXTAUTH_GOOGLE_ID,
clientSecret: process.env.NEXTAUTH_GOOGLE_SECRET,
authorizationUrl:
"https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code",
}),
],
jwt: {
encryption: true,
secret: process.env.JWT_SECRET,
signingKey: process.env.SIGNING_KEY,
encryptionKey: process.env.ENCRYPTION_KEY,
},
};
屏幕截图或错误日志
终端登录错误
[next-auth][error][callback_oauth_error] Error: Invalid state returned from oAuth provider
at /Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:46:27
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:26:103)
at _next (/Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:28:194)
at /Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:28:364
at new Promise (<anonymous>)
at /Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:28:97
at /Users/usr/Documents/app/node_modules/next-auth/dist/server/lib/oauth/callback.js:143:17
at /Users/usr/Documents/app/node_modules/next-auth/dist/server/routes/callback.js:58:31
at Generator.next (<anonymous>)
https://next-auth.js.org/errors#callback_oauth_error
解决方案尝试
在选项中使用了 state: false
。但是,它并没有帮助我解决这个问题。但是,在我每次登录时将此值放入提供程序后,它再次让我回到登录页面.