Questions tagged [next-auth]

NextAuth.js is a open source authentication solution for Next.js applications. This tag is rarely used alone and is most often used in conjunction with [next.js]

1602 questions
0
votes
1 answer

NextAuth - Doesn't redirect to callback url but stays on the singin page

I am working on nextjs & nextauth projects, with a custom sign-in page. Below are the configurations Package.json "next": "^12.0.8" "next-auth": "^4.2.1" [..nextauth].js pages:{ signIn:'/auth/signin' }, callbacks: { async redirect({ url,…
0
votes
1 answer

How to only change selected state value from useDispatch function in redux

I am using google OAuth for authentication in the nextJS project with next-auth and on login, I store the name, email in the store. but in the initial state, I have many state values and when I try to change only two-state values i.e name and email…
0
votes
0 answers

Can the redirect and callbackUrl be used in conjunction on the NextAuth signIn function?

I'm creating an login with NextAuth in my Next.js app. Before I login, I restrict certain routes, only accessible if a user has been authorized. With NextAuth Credentials Provider, when an error is thrown, it automatically takes you to a template…
0
votes
1 answer

My MongoDB database connection does not re-open upon closing

I'm implementing an Authentication system with NextAuth inside of my Next.js app. I'm using NextAuth Credentials as the provider with my custom login screen. I'm using NextAuth v.4. Previously I have established my connection like represented…
0
votes
0 answers

Is there a reason why session would be undefined?

Hello and thanks in advance for taking a look at this issue. I am using nextAuth for authentication and would like to show pages based on user authentication. Upon running this code below, it returns 'undefined' for session. However, I followed the…
Xhris
  • 55
  • 7
0
votes
1 answer

ServerError: TypeError: Cannot convert undefined or null to object

I'm trying to do signIn with nextauth.js. My code is given below: import { getProviders, signIn as SignIntoProvider } from 'next-auth/react' import Header from '../../Components/Header' function signIn({ providers }) { return ( <> …
Krunal
  • 21
  • 1
  • 3
0
votes
1 answer

Next-Auth EmailProvider and FaunaAdapter "Unable to Sign In"

I've followed the next-auth docs to hook up its EmailProvider and FaunaAdapter in a brand new Next.js project, but I am unable to sign in. My dependencies: "@next-auth/fauna-adapter": "^1.0.2" "faunadb": "^4.5.2" "next": "^12.1.0" "next-auth":…
Teagan Atwater
  • 178
  • 1
  • 3
  • 10
0
votes
1 answer

restrict sign and signup page after auth nextauth nextjs

I'm trying to restrict sign and signup page after auth in nextauth nextjs through the given middleware: import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; export async function middleware(req) { const url =…
user17999103
0
votes
0 answers

Next Auth authentication in production

I finished developing my application with Next.js. I used Next Auth to handle user authentication. I use the Credential Provider for authentication with email and password. In development everything works fine when I log in the session is well…
BibDev
  • 349
  • 2
  • 4
  • 12
0
votes
1 answer

Error when encoding and decoding jwt on next-auth

On next-auth when just using the callbacks object https://next-auth.js.org/configuration/callbacks everything works fine, I can log in with google. and a jwt gets correctly generated. callbacks: { async jwt({ token }) { …
0
votes
0 answers

next-auth custom auth window not defined

I am trying to use next-auth with my backend but it doesn't work. I use version 4 with typescript. The error is {error: 'window is not defined', status: 200, ok: true, url: null} Why?????. Thanks a lot. My custom API /login result is { "data":…
Bonci Marco
  • 301
  • 2
  • 5
  • 17
0
votes
2 answers

NextAuth fetching api endpoint - req.body undefined

I'm trying to use NextAuth.js for authentication in my Next.js app, using the following code from documentation: authorize: async(credentials, req) => { const res = await fetch("http://localhost:3000/api/userverify", { method: 'POST', …
TheSillus
  • 19
  • 2
0
votes
1 answer

How to add middleware in the client side in Next.js using nextAuth

-pages -----admin +++++++++index.js How to create a middleware so that if user is not logged in to be redirected in a page?
n9p4
  • 304
  • 8
  • 34
0
votes
1 answer

NextAuth JS Removing keys from JWT

I am currently using the credentials provider to verify a user on an LDAP. I am also using Hasura as a backend which requires certain claims in the jwt. So a custom encode and decode function is required. This is where i run into my issues. If i…
Law
  • 51
  • 1
0
votes
0 answers

Is useSession/getSession really serverless in next-auth?

One thing I can't wrap my head around considering using next-auth is if useSession/getSession really is serverless. If I understand it correctly useSession/getSession is the glue for data-availability within next-auth. I know what sessions are but…