Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set redirect_uri for Google authentication provider #664

Open
matthewairalo opened this issue Feb 12, 2024 · 2 comments
Open

Cannot set redirect_uri for Google authentication provider #664

matthewairalo opened this issue Feb 12, 2024 · 2 comments
Labels
bug A bug that needs to be resolved p3 Minor issue provider-authjs An issue with the authjs provider

Comments

@matthewairalo
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v20.10.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.0
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

No response

Describe the bug

I cannot set a custom redirect uri for the Google provider. It always seems to just send the default /api/auth/providers/google instead, which results in an error from Google authenticator due to redirect_uri mismatch.

Here's my configuration:

nuxt.config.js

auth: {
    provider: {
      type: 'authjs',
      token: '',
      addDefaultCallbackUrl: false,
      globalAppMiddleware: false,
    },
    addDefaultCallbackUrl: false,
    baseURL: '/nuxt-api/auth',
  },

server/routes/nuxt-api/auth/[...].ts (yes, I am trying every option that came to my mind)

  providers: [
    // @ts-ignore Import is exported on .default during SSR, so we need to call it this way. May be fixed via Vite at some point
    GoogleProvider.default({
      clientId: process.env.GOOGLE_APPID,
      options: {
        callbackUrl: `${process.env.APP_URL}/auth/callback`,
        callback_url: `${process.env.APP_URL}/auth/callback`,
        redirect_uri: `${process.env.APP_URL}/auth/callback`,
        redirectUri: `${process.env.APP_URL}/auth/callback`,
        redirect_url: `${process.env.APP_URL}/auth/callback`,
        redirectUrl: `${process.env.APP_URL}/auth/callback`,
        user: false,
      },
      callbackUrl: `${process.env.APP_URL}/auth/callback`,
      callback_url: `${process.env.APP_URL}/auth/callback`,
      redirect_uri: `${process.env.APP_URL}/auth/callback`,
      redirectUri: `${process.env.APP_URL}/auth/callback`,
      redirect_url: `${process.env.APP_URL}/auth/callback`,
      redirectUrl: `${process.env.APP_URL}/auth/callback`,
    }),
  ],

Additional context

No response

Logs

No response

@matthewairalo
Copy link
Author

Similar issues with any provider. All seem to be using the default /api/auth/callback/:provider: route.

@zoey-kaiser zoey-kaiser added p3 Minor issue bug A bug that needs to be resolved provider-authjs An issue with the authjs provider and removed bug labels Feb 23, 2024
@ElizeoRocha
Copy link

@matthewairalo the redirect_uri worked with this approach for me, I hope it helps you

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved p3 Minor issue provider-authjs An issue with the authjs provider
Projects
None yet
Development

No branches or pull requests

3 participants