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

OAuthCallback error on Netlify #435

Closed
sun-ergo-s opened this issue Jun 12, 2023 · 2 comments
Closed

OAuthCallback error on Netlify #435

sun-ergo-s opened this issue Jun 12, 2023 · 2 comments

Comments

@sun-ergo-s
Copy link

sun-ergo-s commented Jun 12, 2023

Environment

This is my localhost environment:

  • Operating System: Windows_NT
  • Node Version: v16.20.0
  • Nuxt Version: 3.5.3
  • Nitro Version: 2.4.1
  • Package Manager: npm@9.6.6
  • Builder: vite
  • User Config: runtimeConfig, modules, auth
  • Runtime Modules: @sidebase/nuxt-auth@0.6.0-beta.2
  • Build Modules: -

I don't know Netlify environment.

Reproduction

https://github.com/sun-ergo-s/testing-nuxt-on-netlify

Deployed on Netlify: https://whimsical-biscotti-346a06.netlify.app/

Describe the bug

I have a clean install of Nuxt@3.5.3 application with @sidebase/nuxt-auth@0.5.0 (also tried 0.6.0-beta.2).

After deploying on Netlify I got the OAuthCallback error using Google/Facebook provider in URL after redirect.

On localhost everything works fine.

I have defined AUTH_ORIGIN and NEXTAUTH_URL variables on Netlify and also in config file:

auth: {
    origin: process.env.AUTH_ORIGIN
}

Additional context

Works on Vercel. I also tried this solution but it didn't work:

add cookies config

  cookies: {
    pkceCodeVerifier: {
      name: "next-auth.pkce.code_verifier",
      options: {
        httpOnly: true,
        sameSite: "none",
        path: "/",
        secure: true,
      },
    },
  },

Originally posted by @desenmeng in nextauthjs/next-auth#6898 (comment)

Logs

netlify-error

@sun-ergo-s sun-ergo-s added the bug label Jun 12, 2023
@bweisel
Copy link

bweisel commented Aug 10, 2023

+1 on this -- I'm hitting the same issue. Works on Vercel just fine though.

@bweisel
Copy link

bweisel commented Aug 11, 2023

@sun-ergo-s I figured out a fix for this!

The issue was actually in Nitro -- it was not handling the Set-Cookie header properly. Here is the fix: unjs/nitro#1452

You can pull in the latest, edge version of Nitro following the steps here: Hebilicious/authjs-nuxt#51 (comment)

Specifically adding to my package.json file:

"resolutions": {
    "nitropack": "npm:nitropack-edge@latest"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants