You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NextAuth v5 Beta配置遇UnknownAction错误,寻求解决方案

NextAuth AuthJS v5 Beta 配置报错:UnknownAction: Cannot parse action at /api/auth/providers

我在按照NextAuth AuthJS v5 Beta教程配置项目时,出现了错误:[auth][error] UnknownAction: Cannot parse action at /api/auth/providers。官方错误页面未提供修复方案,降级到v4版本后项目可正常运行,但我希望在v5 Beta版本中解决该问题。尝试过删除node_modules重新安装依赖,问题仍未解决。

相关配置文件如下:

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"

内容的提问来源于stack exchange,提问作者Mohammed arbazuddin Qureshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 13:30:22