NextAuth problem in production on Vercel

Hey, I am having trouble using NextAuth in production, despite using it just fine in my development environment. I am using Prisma as well. I tried removing the NEXTAUTH_URL from my environment variables in production based on this https://next-auth.js.org/deployment#vercel, as well as removing the authOptions export from '~/server/auth' based on this https://github.com/vercel/next.js/discussions/50511 Unfortunatley neither of these solutions seemed to work, nor did the solutions that I have looked through here. I am using the Email provider, and the Google provider btw
GitHub
Why does my NextAuthJS discord login work in the test environment b...
Summary I am trying to deploy a NextJS application to vercel. This is a test sign in model using AuthJS. When I run the program using npm run devit works fine and I am able to log in to my discord ...
Deployment | NextAuth.js
Deploying NextAuth.js only requires a few steps. It can be run anywhere a Next.js application can. Therefore, in a default configuration using only JWT session strategy, i.e. without a database, you will only need these few things in addition to your application:
Solution:
i think you just have to add the google provider secrets in the env.
Jump to solution
13 Replies
shivam
shivam4mo ago
you're using t3 stack yes ? if yes, i think you don't have to remove NEXTAUTH_URL
Solution
shivam
shivam4mo ago
i think you just have to add the google provider secrets in the env.
shivam
shivam4mo ago
lmk if it works
Le
LeOP4mo ago
yo thanks for the response I had the google provider secrets in my env, so I think it was something else. I looked at my logs on vercel and saw some prisma erros but I didn't really know how to resolve them. I suspected it had something to do with the direct_url database_url thing, so I scaffolded another project with drizzle to test it out
shivam
shivam4mo ago
did you db:push
Le
LeOP4mo ago
yeah in the drizzle project, the production version google provider works but the email provider still doesn't work it gives me a 504 error
shivam
shivam4mo ago
can you share the code or the error
Le
LeOP4mo ago
sure thing, I will share both. Give me a sec
Le
LeOP4mo ago
⨯ PrismaClientUnknownRequestError: Invalid prisma.user.findUnique() invocation: Error occurred during query execution: ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(PostgresError { code: "42P05", message: "prepared statement "s3" already exists", severity: "ERROR", detail: None, column: None, hint: None }), transient: false }) at _n.handleRequestError (/var/task/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:121:7939) at _n.handleAndLogRequestError (/var/task/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:121:7057) at _n.request (/var/task/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:121:6741) at async l (/var/task/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:130:9355) { name: 'GetUserByEmailError', code: undefined }
shivam
shivam4mo ago
i'll get into it soon, rn with theo on twitch and some work
Le
LeOP4mo ago
no worries, much appreciated
shivam
shivam4mo ago
is it all related to prisma error for prisma error, have you tried the basic stuff like updating the client, restarting the connection and all ?
Le
LeOP4mo ago
Alright the google provider works fine now, I recreated the project, I created another database, and created another google project. I carefully added each environment variable except nextauth_url, then I cleared my site data, and it worked. Before this I did try updating prisma, it didn't seem to be the issue. I'm afraid the issue might have been with the env after all, as I initially just pasted the .env into vercel, but this time I copy-pasted each key and each value separately. The current issue is just the email provider, I get a 504 "This Serverless Function took too long" I changed my smtp server to just gmail now, and the email provider works I will mark your first answer as a solution because it's the closest thing to the solution. Thanks for the assistance
Want results from more Discord servers?
Add your server