#specify google provider redirect url

1 messages · Page 1 of 1 (latest)

cloud radish
#

in production when I try to login with google I get this error from google:
Error 400: redirect_uri_mismatch

You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy.

If you're the app developer, register the redirect URI in the Google Cloud Console.
Request details: redirect_uri=http://localhost:8282/api/auth/callback/google
Related developer documentation

why does next auth v5 sends request from localhost instead of site url, how to fix it?

gilded heraldBOT
#

Hi @cloud radish. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The issue you're facing is related to the NEXTAUTH_URL environment variable. This variable should reflect the URL of your production site, but it seems like it's currently set to <http://localhost:8282.>

To fix this, you need to update your NEXTAUTH_URL environment variable to reflect your production site URL. This is the URL that Google uses to redirect users after they have authenticated with Google.

Here's how you can do it:

  1. In your production environment, set the NEXTAUTH_URL environment variable to your production site URL. For example, if your production site URL is <https://myapp.com,> then NEXTAUTH_URL should be set to <https://myapp.com.>

  2. Update the Authorized redirect URI in your Google OAuth provider settings to match the NEXTAUTH_URL value.

Please note that Google does not allow you to add localhost subdomains as an Authorized redirect URI. If you're testing in a local environment, you can use a different localhost port (e.g. localhost:8888) instead of app.localhost:3000 ^1^.


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@cloud radish kapa.ai is still learning and improving, please let us know how it did by reacting below