Skip to content

Couldn't get session in nextjs middleware #12916

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

Open
Sahil-Gupta584 opened this issue Apr 28, 2025 · 1 comment
Open

Couldn't get session in nextjs middleware #12916

Sahil-Gupta584 opened this issue Apr 28, 2025 · 1 comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@Sahil-Gupta584
Copy link

Environment

  System:
    OS: Windows 11 10.0.26100
    CPU: (8) x64 12th Gen Intel(R) Core(TM) i3-1215U
    Memory: 1.11 GB / 7.71 GB
  Binaries:
    Node: 22.13.1 - C:\nvm4w\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (132.0.2957.140)
  npmPackages:
    @auth/prisma-adapter: ^2.9.0 => 2.9.0 
    next: 15.3.0 => 15.3.0
    next-auth: ^5.0.0-beta.27 => 5.0.0-beta.27
    react: ^19.0.0 => 19.1.0

Reproduction URL

https://github.com/Sahil-Gupta584/authjs-middleware-issue

Describe the issue

I trying to implement route protection in my nextjs project according to doc but in am getting this err:

Image

console>

Image

my middleware.ts simply has>
export { auth as middleware } from "@/auth";

How to reproduce

in nextjs project create a middleware file and write>
export { auth as middleware } from "@/auth

Expected behavior

the middle ware should work

@Sahil-Gupta584 Sahil-Gupta584 added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Apr 28, 2025
@sorcerb
Copy link

sorcerb commented May 3, 2025

In the auth.ts file, you're not using the auth.js library.
There's no point in asking for help about this here.

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