Trying to set up next-auth using a tutorial for next-auth authjs-v5 beta and getting this unknown action error and I am not able to figure whats the issue and the website also doesnt mention a fix just says the error name and nothing else
my package.json
{
"name": "nextlearn",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth/core": "^0.26.3",
"@auth/prisma-adapter": "^1.3.3",
"@hookform/resolvers": "^3.3.4",
"@prisma/client": "^5.9.1",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"bcrypt": "^5.1.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.314.0",
"next": "^14.1.0",
"next-auth": "^5.0.0-beta.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.3",
"react-icons": "^5.0.1",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "^14.1.0",
"postcss": "^8",
"prisma": "^5.9.1",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
auth.ts
import NextAuth from "next-auth"
import { PrismaAdapter } from "@auth/prisma-adapter"
import authConfig from "./auth.config"
import {db} from "@/lib/db"
export const { handlers:{GET,POST}, auth } = NextAuth({
adapter: PrismaAdapter(db),
session: { strategy: "jwt" },
...authConfig,
})
auth.config.ts
import Github from "next-auth/providers/github"
// eslint-disable-next-line import/no-anonymous-default-export
export default {
providers: [Github(
{
clientId: process.env.GITHUB_ID??"",
clientSecret: process.env.GITHUB_SECRET??"",
}
)],
}
app/api/auth/[...nextauth]/route.ts
export {GET,POST} from "@/auth"
any fix would be appreciated.
i tried changing the version to lower version to v4.XX.XX it works but i want it to work on v5 beta and i tried deleting node_modules and it still didn't worked
Was having this same issue when upgrading to next-auth v5. What solved it for me was removing the AUTH_URL
key from my .env file.
This comment was what pointed me in the right direction: https://github.com/nextauthjs/next-auth/issues/9819#issuecomment-1912903196