NextAuth 5:主机必须被信任

q5lcpyga  于 2023-11-18  发布在  其他
关注(0)|答案(1)|浏览(163)

我刚刚用NextJs 14应用程序成功配置了NextAuth 5。然后我在另一台PC上 checkout 了项目,创建了相同的.env文件,现在我在导航到http://localhost:3000/api/auth/signin时遇到了以下错误

[auth][error][N]: Host must be trusted. URL was: http://localhost:3000/api/auth/signin. Read more at https://errors.authjs.dev#n
    at C:\Users\me\projects\my-project\.next\server\chunks\687.js:364:39815
    at nc (C:\Users\me\projects\my-project\.next\server\chunks\687.js:364:41457)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async C:\Users\me\projects\my-project\node_modules\next\dist\compiled\next-server\app-route.runtime.prod.js:6:41304

字符串
与以下页面
x1c 0d1x的数据
有什么想法应该是什么情况下或哪个选项是我错过了?
.env

AUTH_GITHUB_ID=id
AUTH_GITHUB_SECRET=secret
AUTH_SECRET=secret generated using https://generate-secret.vercel.app/32


src/auth.ts

import type { NextAuthConfig } from "next-auth"
import NextAuth from "next-auth"
import GitHub from "next-auth/providers/GitHub"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "@/db"

export const authConfig = {
  providers: [GitHub],
  adapter: DrizzleAdapter(db),
  callbacks: {
    /* does not return ID by default */
    async session({session, user}) {
      session.user.id = user.id
      return session
    },
  }
} satisfies NextAuthConfig

export const { 
  handlers, 
  auth, 
  signOut 
} = NextAuth(authConfig)


src/app/API/auth/[...nextauth]/route.ts

import { handlers } from "@/auth";

export const { GET, POST } = handlers;

fjaof16o

fjaof16o1#

我运行的是npm run start命令而不是npm run dev命令,所以.env没有被选中。

相关问题