2,188 questions
0
votes
1
answer
50
views
NextAuth module augmentation not working in Turborepo monorepo (Property 'id' does not exist on type 'Session.user')
I’m using a Turborepo monorepo with a Next.js 15 App Router project (apps/web) and a shared packages/types package that contains my NextAuth module augmentation.
However, TypeScript still gives this ...
0
votes
1
answer
61
views
NextAuth Google Login Redirect to Localhost instead of Production Domain
I am doing a project which will use Google Login in NextJs
This is my setting in OAuth 2.0
and in amplify environment variables
After I deployed the app and try to login
It redirect me to http://...
0
votes
0
answers
56
views
How to persist data using PrismaAdapter and Authjs
I am trying to persist user data using PrismaAdapter with authjs. But getting following error.
[auth][details]: {}
[auth][error] SessionTokenError: Read more at https://errors.authjs.dev#...
0
votes
0
answers
113
views
How to avoid double login when using NextAuth (GitHub provider) with Giscus comment system?
We’re a small student-led open-source learning platform: "involutionhell" built by volunteers in our spare time. Our website uses NextAuth.js with a GitHub provider for authentication.
...
2
votes
0
answers
85
views
NextAuth sends two refresh requests simultaneously on page reload (refresh token rotation)
I'm using NextAuth with a custom backend in my Next.js app.
When I refresh the page, two refresh requests are sent almost simultaneously.
The first request correctly calls /auth/refresh and gets a new ...
0
votes
0
answers
81
views
google auth + firebase hosting + nextJS: State cookie was missing
I am developing an app in nextJS using next-auth for authentication. So far I only have Google as provider. The app is hosted using firebase hosting.
Running the app in localhost works fine, but when ...
0
votes
0
answers
48
views
Need help updating token in next auth. (next.js app router)
I have a Next.js frontend and NestJS backend.
In the backend there is token generation with refresh token rotation logic, and I want to use the same tokens in the frontend with NextAuth setup.
Here’s ...
0
votes
1
answer
45
views
Unable to add a custom type to AdapterUser of MongoDBAdapter in "@auth/mongodb-adapter"
I have MongoDBAdapter as the adapter in my next-auth config, and I want to add a role to my user, so for that for that i made a next-auth.d.ts file, but it still shows me the error of type not ...
0
votes
0
answers
45
views
NextAuth (Auth.js v5 Beta) is building the callbackUrl using localhost:3000 in Production in Next.js v15.5
I have a Next.js v15.5 app directory frontend project with TypeScript and NextAuth v5 Beta. I have enabled the credentials provider from NextAuth, and everything works just fine locally, but in ...
0
votes
0
answers
83
views
How does authjs (next-auth) store session data?
I used next-auth@beta in my Next project.
I also used credential provider to perform authentication against my database where it stores all the users in a MySQL table. Some basic information such as ...
0
votes
0
answers
30
views
T3 Stack Page Routing Boilerplate does not work
I am trying to create an app using the T3 stack. I am following the instructions in the T3 documentation which start by telling us to use the command npm create t3-app@latest. After doing that, we get ...
0
votes
1
answer
128
views
Next-Auth: JWT callback returns large token → split into .0, .1, .2 cookies
I’m using next-auth with the JWT session strategy and running into a problem with cookie size when storing multiple API tokens.
Here’s my JWT callback:
async jwt({ token, user }) {
if (user) {
...
0
votes
1
answer
152
views
Middleware function from Auth.js exceeds Vercel 1 MB limit
My application uses Auth.js (NextAuth.js v5) to authenticate. In local, it works fine, but when deploying to Vercel problems arise with the "middleware function size". I tried to "...
0
votes
1
answer
118
views
Multiple authentication methods in NextJS with Auth.js
I want to be able to authenticate users with Oauth and protect the API endpoints with Basic authentication. How can I achieve this? My currently configuration doesn't work, unless I remove the Basic ...
0
votes
0
answers
44
views
Handling Invalid Login Errors in AWS Cognito with Auth.js (Formerly NextAuth) using SRP Authentication Flow
I'm working on creating a custom login and sign-up page using AWS Cognito with the SRP (Secure Remote Password) authentication flow. For handling the session, I’m using Auth.js (previously NextAuth), ...
0
votes
2
answers
201
views
Middleware not triggering in Next.js app using next-auth
I’m working on a Next.js 14 app with the App Router and next-auth@5. I followed the official Next.js Learn guide on authentication, except I replaced email with username in the database.
I set up ...
0
votes
0
answers
40
views
Getting NextAuth "CLIENT_FETCH_ERROR" when I try to add a basePath in NextConfig
I implemented NextAuth in my application for basic authentication and authorization. The system works perfectly when I didnt add any basePath in NextConfig located in next.config.ts but when I added ...
1
vote
0
answers
125
views
Rotate JWT token in Auth.js (Next Auth) before session expiration
I develop a Next.js app with Auth.js v5 security. I use jwt strategy for sessions
I'm trying to achieve lightweight authorization checks in my Next.js app by injecting user roles into JWT payload
...
0
votes
1
answer
149
views
Next.js basePath in combination with next-auth and Keycloak
I created a Next.js Project to test my keycloak server. The programm works fine and does exactly what I want. Until I add the basePath "/app" in my next.config.js:
const basePath = "/...
2
votes
2
answers
549
views
AuthJS / Next-Auth using middleware getting error
I am developing an application to learn NextJS and getting deeper to its concepts.
Im following a course that teaches most needed things to build a full-stack application using NextJS.
The stack I'm ...
0
votes
0
answers
34
views
NextAuth v5 req.auth Undefined with `wrangler pages dev` on Cloudflare Pages, Works with `npm run dev`
I'm using NextAuth v5 with Next.js 15.3.2 for authentication with JWT strategy. Everything works as expected when running the app locally using:
npm run dev
The req.auth object in my middleware is ...
0
votes
1
answer
66
views
Custom expiry time in jwt token in NextAuth
How to set custom expiry time for jwt in next-auth, i want to setup the time based on remember me marked on the frontend, but when setting token.exp in jwt callback nothing happens, the token expiry ...
0
votes
0
answers
82
views
next-auth - How to pass a Bearer token from external provider to fetch external API
Our Next.js app (app router) is using next-auth for security with a Keycloak oauth provider. We're using Next API routes to fetch from another REST API for data fetching and manipulation. What is the ...
0
votes
0
answers
29
views
How to fetch session in RootLayout/Header without making the whole app dynamic?
I'm building an ecommerce site using Next.js App Router (v13+). About 80% of my pages are static and ideally should remain static for performance and caching benefits.
However, when I fetch the user ...
0
votes
1
answer
52
views
Middleware is not being triggered
I'm using next-auth with middleware.ts in a Next.js App Router project. Despite putting middleware.ts at the root of the project, it is not being triggered, and protected routes like /profile are ...
0
votes
0
answers
48
views
NextAuth LinkedIn OAuth returns blank page after login – no API calls in LinkedIn Analytics
I am trying to create a LinkedIn based authentication using typescript, but since long I am failing. My code is successfully able to give me login option using LinkedIn but when I login, it just gives ...
0
votes
0
answers
21
views
What could be causing NextAuth with Google provider to fail in production (Vercel) despite correct callback URLs and environment variables?
enter image description here
GOOGLE_CLIENT_ID=********.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=********
AUTH_SECRET=JSR+v4MCFEAMAOMtEcXYeh5nJCnVrKJaY0czK1byVhI=
DATABASE_URL=postgresql://user:...
0
votes
1
answer
74
views
How to implement lazy initialization of authjs config in nextjs?
How to implement lazy initialization of authjs (v5 beta) config in nextjs 14 without encountering the error Error: The Middleware "/src/middleware" must export a middleware or a default ...
0
votes
2
answers
52
views
In SSR pages, if the API responds with a 401 status, then sign out
I am a newbie with next-auth. my app still uses a frontend and backend separation, and I'm using CredentailProvider for login to obtain an access token from the backend server. when I fetch data from ...
4
votes
0
answers
295
views
Prisma Adapter with Auth.js in Next.js 15 on Vercel (Edge Runtime Issue)
I have a Turbo repo with the following structure:
- apps
- web
- Next.js 15
- packages
- @repo/database
- Prisma v6.8
- @repo/authjs-core
- Auth.js v5
- Providers
- ...
0
votes
0
answers
108
views
Next.js Middleware Error: "Cannot read properties of undefined (reading 'substring')" in oidc-token-hash
I'm implementing authentication middleware in a Next.js (v13+) application using NextAuth.js, and I'm encountering an error when trying to validate the session token. The error occurs in the oidc-...
1
vote
0
answers
147
views
Why is sidebase/nuxt-auth not working in production without ssr?
I'm using sidebase's nuxt-auth to setup authentication, and everything works fine in development mode, but not when deployed with npm run build. Specifically, the getServerSession() function always ...
0
votes
2
answers
45
views
Next JS Auth - Dynamic path not being protected
I am not being able to protect under Next Auth the dynamic paths [slug]. Nested paths like [slug]/nested-page are being protected and redirected to login page when the user is not logged as intended, ...
0
votes
1
answer
106
views
NextAuth v5 deployment error with Next.js 15: "handlers is not a valid Route export field"
Problem
I'm trying to deploy a Next.js 15.3.2 application for the past 4 hours with NextAuth v5 (beta.27) to Vercel, but I'm encountering a build error during deployment:
Failed to compile.
src/app/...
0
votes
0
answers
18
views
How to prevent other signed-in Microsoft accounts in the browser from interfering with NextAuth AzureAD session?
I'm building a Next.js application using next-auth with the AzureAD provider. My users sign in using their Microsoft accounts, and the authentication generally works well.
However, I’ve run into a ...
0
votes
0
answers
31
views
NextAuth.js bind error in production (HTTP Error 500)
I am working on a project with a few of my fellow students colleagues. The website runs locally exactly how it is supposed to.
Env variables:
### NextAuth ###
NEXTAUTH_URL="https://placeholder-...
1
vote
1
answer
154
views
Next.js, Typescript, PostgreSQL and NextAuth.js 4.24.11 error: Module '"next-auth"' has no exported member 'NextAuthOptions'.ts(2305)
I want to let people sign in to my Next.js Typescript application using GitHub. I am storing the users in a PostgreSQL database table. Everything runs on Google Cloud Run.
But in my app/lib/auth.ts ...
0
votes
2
answers
68
views
Redirect and Sign In issues with NextAuth
In my NextJS, I am using NextAuth. I have sign in/sign up with credentials and Google set up. The problem I am having is of redirect. I have made this middleware:
export { default } from 'next-auth/...
0
votes
0
answers
31
views
NextAuth.js Error: The column `User.verificationToken` does not exist in the current database
I'm using NextAuth.js for my application. When I try to create an account I get the 'something went wrong' error. Even though the User table has a verificationToken column, I get this message in the ...
0
votes
0
answers
20
views
auth/next.js bug with authnext.js
i have a problme when i try to login with google i can login, but when i try to login with credentialsProvider i got undefined in my seesion and i can't login to my page, though i have the user from ...
1
vote
1
answer
162
views
Nextauth unable to do next build with error o is not a function inside [...nextauth]/route.js
When I am trying to do next build to prepare my application for production, the next build script always stuck at collect page data, with the following error:
TypeError: o is not a function
#13 89.81 ...
0
votes
1
answer
74
views
Getting "NEXTAUTH_SECRET is not set in environment variables" during Vercel deployment, even though it is set correctly
When I run npm run build locally, I don't get any errors and the build completes successfully. However, when I try to deploy the project on Vercel, I get the following error:
Error: NEXTAUTH_SECRET is ...
0
votes
0
answers
61
views
How can I implement a Custom OAuth Provider for My NextJS Application?
so I've read the documentation at
https://next-auth.js.org/configuration/providers/oauth
I have received a client secret and such from my corportate oAuth provider but for the life of me I can't ...
1
vote
0
answers
42
views
next-auth Sign in with Apple Testing on Development server
I'm trying to implement a sign-in-with-apple feature for my Web-application. To do that im using next-auth as a 3rd party library. Now after setting up my apple client ID and Secret I want to test it ...
0
votes
0
answers
32
views
NextAuth.js GitHub provider returns "AccessDenied" and profile is undefined during sign-in
I’ve been trying to fix this error for over a day now and can’t seem to figure it out.
Whenever I try to log in with GitHub using NextAuth.js, I get this error in the terminal: Error: Unauthorized - ...
0
votes
0
answers
53
views
UntrustedHost: Host must be trusted. URL was: in next-auth /auth.js in next.js
UntrustedHost: Host must be trusted. The URL was:
This means your Amplify domain is not trusted by Auth.js, and the framework is rejecting any auth-related requests to/from it. This is a security ...
0
votes
1
answer
173
views
AWS Cognito Hosted UI Login - How to "delete AWS' cookie or Log the user out" from the Hosted UI post-login?
I have a NextJS application that is using AWS Cognito for the User Authentication system. We are using AuthJS@5 to integrate with AWS Cognito. After clicking sign-in, the user gets redirected to AWS ...
0
votes
0
answers
24
views
How to logout if JWT token refreshing fails in Next.js?
I have the following callbacks configured in my Next.js 15 project that uses next-auth 5.
callbacks: {
async authorized({
auth,
request: {
nextUrl
}
}) {
const isLoggedIn = !!...
1
vote
2
answers
246
views
NextJS 15 Authentication: How to get the auth session
I am trying to make the authentication flow for NextJS 15 with app routing. I managed to set up the login logic, saving the encrypted authentication session in a cookie and the logout flow. Now the ...
0
votes
0
answers
23
views
new async authorize function for NextAuth5 (auth.js) and Next.JS 15
ALL implementations of the authorize function of NextAuth found on the web are false/deprecated with new Next.JS 15 and new NextAuth 5 (new auth.js) like this :
async authorize(credentials: any) {
...