adrianhajdin / project_nextjs13_flexibble

https://jsmastery.pro
655 stars 141 forks source link

JWT_SESSION_ERROR #14

Open rne1223 opened 1 year ago

rne1223 commented 1 year ago

Having a hard time figuring out how to refresh JWT. It seems that it expired and now I'm not able to login to the dev website. Here is the errors that I'm getting:

- event compiled client and server successfully in 1481 ms (1336 modules)
[next-auth][warn][EXPERIMENTAL_API] 
`getServerSession` is used in a React Server Component.
https://next-auth.js.org/configuration/nextjs#getServerSession}
https://next-auth.js.org/warnings#EXPERIMENTAL_API
[next-auth][error][JWT_SESSION_ERROR]
https://next-auth.js.org/errors#jwt_session_error invalid signature {
  message: 'invalid signature',
  stack: 'JsonWebTokenError: invalid signature\n' +
    '    at eval (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:158:25)\n' +
    '    at getSecret (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:94:20)\n' +
    '    at module.exports [as verify] (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:97:12)\n' +
    '    at Object.decode (webpack-internal:///(sc_server)/./lib/session.ts:32:86)\n' +
    '    at Object.session (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/session.js:25:44)\n' +
    '    at AuthHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:161:50)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
    '    at async getServerSession (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:129:21)\n' +
    '    at async getCurrentUser (webpack-internal:///(sc_server)/./lib/session.ts:76:21)\n' +
    '    at async Navbar (webpack-internal:///(sc_server)/./components/Navbar.tsx:25:21)',
  name: 'JsonWebTokenError'
}
[next-auth][error][JWT_SESSION_ERROR] 
https://next-auth.js.org/errors#jwt_session_error invalid signature {
  message: 'invalid signature',
  stack: 'JsonWebTokenError: invalid signature\n' +
    '    at eval (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:158:25)\n' +
    '    at getSecret (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:94:20)\n' +
    '    at module.exports [as verify] (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:97:12)\n' +
    '    at Object.decode (webpack-internal:///(sc_server)/./lib/session.ts:32:86)\n' +
    '    at Object.session (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/session.js:25:44)\n' +
    '    at AuthHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:161:50)\n' +
    '    at async getServerSession (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:129:21)\n' +
    '    at async getCurrentUser (webpack-internal:///(sc_server)/./lib/session.ts:76:21)\n' +
    '    at async Navbar (webpack-internal:///(sc_server)/./components/Navbar.tsx:25:21)',
  name: 'JsonWebTokenError'
}
[next-auth][error][JWT_SESSION_ERROR] 
https://next-auth.js.org/errors#jwt_session_error invalid signature {
  message: 'invalid signature',
  stack: 'JsonWebTokenError: invalid signature\n' +
    '    at eval (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:158:25)\n' +
    '    at getSecret (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:94:20)\n' +
    '    at module.exports [as verify] (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:97:12)\n' +
    '    at Object.decode (webpack-internal:///(sc_server)/./lib/session.ts:32:86)\n' +
    '    at Object.session (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/session.js:25:44)\n' +
    '    at AuthHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:161:50)\n' +
    '    at async getServerSession (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:129:21)\n' +
    '    at async getCurrentUser (webpack-internal:///(sc_server)/./lib/session.ts:76:21)\n' +
    '    at async Navbar (webpack-internal:///(sc_server)/./components/Navbar.tsx:25:21)',
  name: 'JsonWebTokenError'
}
[next-auth][error][JWT_SESSION_ERROR] 
https://next-auth.js.org/errors#jwt_session_error invalid signature {
  message: 'invalid signature',
  stack: 'JsonWebTokenError: invalid signature\n' +
    '    at eval (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:158:25)\n' +
    '    at getSecret (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:94:20)\n' +
    '    at module.exports [as verify] (webpack-internal:///(sc_server)/./node_modules/.pnpm/jsonwebtoken@9.0.0/node_modules/jsonwebtoken/verify.js:97:12)\n' +
    '    at Object.decode (webpack-internal:///(sc_server)/./lib/session.ts:32:86)\n' +
    '    at Object.session (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/session.js:25:44)\n' +
    '    at AuthHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:161:50)\n' +
    '    at async getServerSession (webpack-internal:///(sc_server)/./node_modules/.pnpm/next-auth@4.22.1_next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:129:21)\n' +
    '    at async getCurrentUser (webpack-internal:///(sc_server)/./lib/session.ts:76:21)\n' +
    '    at async Navbar (webpack-internal:///(sc_server)/./components/Navbar.tsx:25:21)',
  name: 'JsonWebTokenError'
}

Any help would be greatly appreciate it. Thanks.

Joaquin144 commented 1 year ago

I am getting the same message. Did you solve it ?

rne1223 commented 1 year ago

Solved it by making sure that linkedInUrl in grafbase.config.ts is defined the same way in graphql/index.ts.

Teegreat commented 1 year ago

still no fix yet

mariawarnes commented 1 year ago

I had the same issue and realised that grafbase wasn't running: npx grafbase dev and then you might get some more helpful error messages showing you where any other issues are