You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trying to fetch() from the route immediately returns a 500 internal error.
There were no issues when initializing NextAuth with an object instead of a function. Instead of creating a new PostgreSQL Pool instance within NextAuth (as shown in the database integration tutorial), an existing Pool object was imported and used.
// from Auth.js documentationimportNextAuthfrom"next-auth"importPostgresAdapterfrom"@auth/pg-adapter"import{Pool}from"@neondatabase/serverless"// *DO NOT* create a `Pool` here, outside the request handler.// Neon's Postgres cannot keep a pool alive between requests.exportconst{ handlers, auth, signIn, signOut }=NextAuth(()=>{// Create a `Pool` inside the request handler.constpool=newPool({connectionString: process.env.DATABASE_URL})return{adapter: PostgresAdapter(pool),providers: [],}})
How to reproduce
Instantiate NextAuth using a function that doesn’t take any parameters.
Expected behavior
auth() wrapper for route handlers and middleware should work normally.
The text was updated successfully, but these errors were encountered:
jwwhangbo
added
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
Jan 9, 2025
jwwhangbo
changed the title
[NEXTjs] app router route handler / middleware wrapper for auth((req) => {}) not working correctly when instantiating NextAuth() using a function.
[NEXTjs] app router route handler / middleware wrapper for auth((req) => {}) not working correctly when initializing NextAuth() using a function.
Jan 9, 2025
jwwhangbo
changed the title
[NEXTjs] app router route handler / middleware wrapper for auth((req) => {}) not working correctly when initializing NextAuth() using a function.
[NEXTjs] app router route handler / middleware wrapper auth((req) => {}) not working correctly when initializing NextAuth() using a function.
Jan 9, 2025
jwwhangbo
changed the title
[NEXTjs] app router route handler / middleware wrapper auth((req) => {}) not working correctly when initializing NextAuth() using a function.
[NEXTjs] app router route handler / middleware wrapper auth((req) => {}) not working properly when initializing NextAuth() using a function.
Jan 9, 2025
Environment
System:
OS: macOS 15.2
CPU: (8) arm64 Apple M2
Memory: 167.84 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.5.0 - /usr/local/bin/node
npm: 11.0.0 - /opt/homebrew/bin/npm
pnpm: 9.15.2 - ~/Documents/GitHub/chatgpt-cooking/node_modules/.bin/pnpm
Watchman: 2024.09.02.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 131.0.6778.205
Safari: 18.2
npmPackages:
@auth/core: ^0.37.4 => 0.37.4
@auth/pg-adapter: ^1.7.4 => 1.7.4
@auth/prisma-adapter: ^2.7.4 => 2.7.4
next: 15.1.2 => 15.1.2
next-auth: 5.0.0-beta.25 => 5.0.0-beta.25
react: 19.0.0 => 19.0.0
Reproduction URL
https://github.com/jwwhangbo/NibbleAI/blob/PROTOTYPE/app/api/collections/route.ts
Describe the issue
When initializing NextAuth using a function that doesn't take any parameters,
it returns an auth function that doesn't work when used in middleware.ts or route.ts.
trying to fetch() from the route immediately returns a 500 internal error.
There were no issues when initializing NextAuth with an object instead of a function. Instead of creating a new PostgreSQL Pool instance within NextAuth (as shown in the database integration tutorial), an existing Pool object was imported and used.
How to reproduce
Instantiate NextAuth using a function that doesn’t take any parameters.
Expected behavior
auth() wrapper for route handlers and middleware should work normally.
The text was updated successfully, but these errors were encountered: