-
I'm using import { NextApiRequest, NextApiResponse } from 'next';
import NextAuth from 'next-auth';
import Providers from 'next-auth/providers';
const options = {
providers: [
Providers.Google({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
authorizationUrl:
'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code'
}),
Providers.GitHub({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
scope: 'user:email'
})
],
secret: process.env.NEXTAUTH_SECRET,
session: { jwt: true },
jwt: {
secret: process.env.NEXTAUTH_JWT_SECRET,
encryption: true,
signingKey: process.env.NEXTAUTH_JWT_SIGNING_KEY,
encryptionKey: process.env.NEXTAUTH_JWT_ENCRYPTION_KEY
},
callbacks: {
jwt: async (token: { auth_time: number }, user: any) => {
if (user) {
token.auth_time = Math.floor(Date.now() / 1000);
}
return Promise.resolve(token);
}
}
};
export default (req: NextApiRequest, res: NextApiResponse) => NextAuth(req, res, options); Everything works fine in dev and in the local build, however, when deploying to Vercel, I get the error when trying to sign in:
FWIW, a request is made I do not know why this is and I've never seen this error before. My repo for all my code can be found here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This suggests that jwt token generation fails in the Vercel environment and the error (token k and whatnot) further points to JWT_*_KEY env variables not correctly set up in the Vercel project. Not using Vercel myself for hosting, so cannot say where to go and look exactly, but it looks like your key json is in wrong format or escaped differently or something in there. |
Beta Was this translation helpful? Give feedback.
This suggests that jwt token generation fails in the Vercel environment and the error (token k and whatnot) further points to JWT_*_KEY env variables not correctly set up in the Vercel project. Not using Vercel myself for hosting, so cannot say where to go and look exactly, but it looks like your key json is in wrong format or escaped differently or something in there.