Next.js Discord

Discord Forum

Invalid Compact JWE

Answered
SharpieMaster posted this in #help-forum
Open in Discord
Avatar
[next-auth][error][JWT_SESSION_ERROR] 
https://next-auth.js.org/errors#jwt_session_error Invalid Compact JWE {
  message: 'Invalid Compact JWE',
  stack: 'JWEInvalid: Invalid Compact JWE\n' +
    '    at compactDecrypt (webpack-internal:///(rsc)/./node_modules/.pnpm/jose@4.14.6/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js:18:15)\n' +
    '    at jwtDecrypt (webpack-internal:///(rsc)/./node_modules/.pnpm/jose@4.14.6/node_modules/jose/dist/node/cjs/jwt/decrypt.js:10:61)\n' +
    '    at Object.decode (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.1_next@13.5.2_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/jwt/index.js:44:52)\n' +
    '    at async Object.session (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.1_next@13.5.2_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/session.js:25:34)\n' +
    '    at async AuthHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.1_next@13.5.2_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:161:37)\n' +
    '    at async getServerSession (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.1_next@13.5.2_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:125:21)\n' +
    '    at async RootLayout (webpack-internal:///(rsc)/./src/app/layout.tsx:24:21)',
  name: 'JWEInvalid'
}
Answered by SharpieMaster
Bro I just re installed packages and that F*CKING FIXED IT???
View full answer

14 Replies

Avatar
// src/api/auth/[...nextauth]/route.ts

import NextAuth from "next-auth";
import GithubProvider from "next-auth/providers/github";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { prisma } from "@/server/db/client";

const adapter = NextAuth({
    adapter: PrismaAdapter(prisma),
    providers: [
        GithubProvider({
            clientId: process.env.GITHUB_ID ?? "",
            clientSecret: process.env.GITHUB_SECRET ?? "",
        }),
    ],
});

export { adapter as GET, adapter as POST };
I have correct schema.prisma
// src/server/db/client.ts

import { PrismaClient } from "@prisma/client";

declare global {
    var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
Image
Avatar
please help
Avatar
European sprat
you have the next auth secret set in your env?
Avatar
Image
I do
"dependencies": {
        "@next-auth/prisma-adapter": "^1.0.7",
        "@prisma/client": "5.3.1",
        "@types/node": "20.6.2",
        "@types/react": "18.2.21",
        "@types/react-dom": "18.2.7",
        "autoprefixer": "10.4.15",
        "bcrypt": "^5.1.1",
        "eslint": "8.49.0",
        "eslint-config-next": "13.4.19",
        "next": "13.5.2",
        "postcss": "8.4.29",
        "prettier": "^3.0.3",
        "react": "18.2.0",
        "react-dom": "18.2.0",
        "tailwindcss": "3.3.3",
        "typescript": "5.2.2"
    },
    "devDependencies": {
        "next-auth": "^4.23.1",
        "prisma": "^5.3.1"
    }
Avatar
dont leave me like this, please
Avatar
European sprat
I don't use next-auth so I don't know what else to suggest
Good luck
Avatar
thx for trying
Avatar
Bro I just re installed packages and that F*CKING FIXED IT???
Answer