Relative Content

Tag Archive for next.jsnext-auth

Next.js request.nextUrl.pathname return always /

In nextjs , I am trying to get current url path in middleware by using request.nextUrl.pathname. Currently request.nextUrl.pathname always return ‘/’ for any route. For example when I try with http://localhost:3000/dashboard, request.nextUrl.pathname returns ‘/’ but I expect /dashboard. What do I miss ?

Why does redirect not happen immediately when visiting a page with Next.js and next-auth?

I have a client-side component where I call the useSession method from the next-auth library, and if the user is not logged in, I redirect them. The problem is, when I visit the /clientmember page while logged out, the page opens and shortly after, it redirects asking me to log in. Why doesn’t the redirect happen immediately when the page is first loaded?

Sign in oAuthCallback Error in next js 14 or above using google providers

I am creating sign in functionality using Next-Auth with google providers i have created a dropdown menu in this menu user will be able to click and then click on sign-in button. it redirects to api/auth/signin?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2F where user selects the sign in with goole after clicking sign-in with google it leads to email and password verification page. where user enters email and password after verification it didn’t redirect to my application and shows errors. here are the errors

Next.js/next-auth: Additional variable added to session but not available when using getServerSession()

I’m working on a Next.js application where I’m using next-auth for authentication. I’ve been trying to add an additional variable to the user session to store custom data. I’ve updated the authentication routine accordingly and added the additional variable to the session. However, when I access the session using getServerSession(), the additional variable doesn’t seem to be available.

Next js 14 + NextAuth.js v5 on production with Nginx what should i set the AUTH_URL

what should I set the AUTH_URL on production while I am deploying the project using Nginx web server when i set AUTH_URL domain name the project does run
I get error Request Header Or Cookie Too Large
while if I keep localhost:3000 the project run while but on error it redirect to localhost:3000/error
Because the baseUrl in next auth is localhost:3000
this is nginx config

nextjs callbacks authorized never called

Using the following NextAuthConfig (with some areas redacted), I cannot get callbacks.authorized to fire. It is mentioned in the official docs https://authjs.dev/reference/next-auth#authorized with some kind of dependency on middleware, though that does not seem clear to me. Any ideas?