복호화 에러 stack: 'JWEDecryptionFailed: decryption operation failed'

j_wisdom_h·2023년 12월 13일
0

Error

목록 보기
8/8

1. 에러

복호화 에러 stack: 'JWEDecryptionFailed: decryption operation failed'

[next-auth][error][JWT_SESSION_ERROR] 
https://next-auth.js.org/errors#jwt_session_error decryption operation failed {
  message: 'decryption operation failed',
  stack: 'JWEDecryptionFailed: decryption operation failed\n' +
    '    at gcmDecrypt (webpack-internal:///(rsc)/./node_modules/jose/dist/node/cjs/runtime/decrypt.js:68:15)\n' +
    '    at decrypt (webpack-internal:///(rsc)/./node_modules/jose/dist/node/cjs/runtime/decrypt.js:91:20)\n' +
    '    at flattenedDecrypt (webpack-internal:///(rsc)/./node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js:117:52)\n' +
    '    at async compactDecrypt (webpack-internal:///(rsc)/./node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js:20:23)\n' +
    '    at async jwtDecrypt (webpack-internal:///(rsc)/./node_modules/jose/dist/node/cjs/jwt/decrypt.js:10:23)\n' +
    '    at async Object.decode (webpack-internal:///(rsc)/./node_modules/next-auth/jwt/index.js:44:25)\n' +
    '    at async Object.session (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/session.js:25:34)\n' +
    '    at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:161:37)\n' +
    '    at async getServerSession (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:125:21)\n' +
    '    at async SignPage (webpack-internal:///(rsc)/./src/app/auth/signin/page.tsx:24:21)',
  name: 'JWEDecryptionFailed'
}

2. 에러 해결

복호화에 쓸 비밀 키를 .env.local에 등록한다.

https://1password.com/ko/password-generator/
간단하게 위 사이트에서 랜덤으로 키를 생성했다.

export const authOptions: NextAuthOptions = { 
  ... ,
  // 추가
  secret: process.env.NEXTAUTH_SECRET
}
const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }
profile
뚜잇뚜잇 FE개발자

0개의 댓글