Provider invalid OAuth2 redirect_uri

I am getting an error when I try to sign in with Discord on my prod environment. I don't have this issue locally I get Invalid OAuth2 redirect_uri and I checked the browser logs
GET
https://discord.com/api/v9/oauth2/authorize?client_id=1344915763433308160&response_type=code&redirect_uri=https://mercury-development.up.railway.app/api/auth/callback/discord&scope=identify email&state=mU-CwQ_BRKfaE3x6a3t8_0cKiRnUFu4R&integration_type=0
GET
https://discord.com/api/v9/oauth2/authorize?client_id=1344915763433308160&response_type=code&redirect_uri=https://mercury-development.up.railway.app/api/auth/callback/discord&scope=identify email&state=mU-CwQ_BRKfaE3x6a3t8_0cKiRnUFu4R&integration_type=0
The redirect uri is the backend where better-auth is set up https://mercury-development.up.railway.app/api/auth/callback/discord the request cookie has the __secure prefix I think my oauth2 redirect uri is set up correctly, it's basically the same for local and prod as well
No description
4 Replies
bxr
bxrOP2w ago
I also noticed regular sign-in just stuck loading so not sure if that also plays part in this
No description
bxr
bxrOP2w ago
but registration works, my user was created in the DB
Beast.-
Beast.-7d ago
I think that it might have something to do with your clientIDs client_id=1344915763433308160 redirect_uri=https://mercury-development.up.railway.app/api/auth/callback/discord But I cant see that redirect_uri in your oauth panel for that specified ID.
bxr
bxrOP4d ago
yeah good catch i did not notice that. My backend env var change didn't go through

Did you find this page helpful?