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

auth() returns null in route handler when a user is signed in via Google #11730

Open
JihongGan opened this issue Aug 30, 2024 · 1 comment
Open
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@JihongGan
Copy link

Environment

  System:
    OS: macOS 14.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 587.47 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.5.1 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 128.0.6613.86
    Safari: 17.2.1
  npmPackages:
    @auth/unstorage-adapter: ^2.0.0 => 2.4.2
    next: latest => 14.2.7
    next-auth: beta => 5.0.0-beta.20
    react: ^18.2.0 => 18.3.1

Reproduction URL

https://github.com/JihongGan/next-auth-example

Describe the issue

In the example app's catch-all handler app/[...proxy]/route.tsx, auth() returns null even when a user is signed in via Google.

How to reproduce

  1. Run the example app fork in the repro link following its readme
  2. Sign in via Google at http://localhost:3000
  3. Call the catch-all handler by visiting http://localhost:3000/foo
  4. Observe that console logs error Authentication failed, since session is null
async function handler(request: NextRequest) {
  const session = await auth()
  if (!session) {
    console.error("Authentication failed");
  }
...
}

Expected behavior

session should not be null and console should not log the error message.

@JihongGan JihongGan added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Aug 30, 2024
@apuntovanini
Copy link

Any news on this? @JihongGan did you manage to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

2 participants