Next.js Discord

Discord Forum

Next Auth does not work in production

Unanswered
Kurilian Bobtail posted this in #help-forum
Open in Discord
Avatar
Kurilian BobtailOP
I have an application that uses next auth and it works perfectly in development, but in production when I try to log in, I receive the following error: https://my.domain.here/api/auth/error?error=fetch%20failed

I have another application that uses EXACTLY the same configuration and works perfectly in development and production, can anyone help me understand what is happening?

9 Replies

Avatar
American Fuzzy Lop
Do you have the env variables set up on prod?
Avatar
Kurilian BobtailOP
yes, all needed variables: NEXT_PUBLIC_API_URL, NEXTAUTH_SECRET, NEXTAUTH_URL
Avatar
American Fuzzy Lop
can you share the code for your auth route?
Avatar
Kurilian BobtailOP
do you talk about [...nextauth].js file?
Avatar
American Fuzzy Lop
yes
Avatar
Kurilian BobtailOP
Image
Avatar
Kurilian BobtailOP
@American Fuzzy Lop some idea?
Avatar
American Fuzzy Lop
@Kurilian Bobtail sorry was at the gym, what error code are u getting besides the error message?
Avatar
Kurilian BobtailOP
401