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

NextAuth.js接入Google认证遇500错误,请求技术帮助

NextAuth.js Google认证遇到500内部服务器错误求助

我按照NextAuth官方指南在现有Next.js应用中添加Google认证,通过Firebase注册应用获取了GOOGLE_ID和GOOGLE_SECRET,配置后遇到以下问题:

点击登录触发跳转后,页面显示“Login With Google”按钮,但点击该按钮出现500内部服务器错误,对应URL为http://localhost:3000/api/auth/signin/google,终端同时提示ReferenceError: ReadableStream is not defined。

另外,Google控制台里找不到我在Firebase注册的应用痕迹,尝试手动创建OAuth客户端获取新凭据、更换Google账号后问题依旧。

相关配置代码

[...nextauth].js

import NextAuth from "next-auth";

import GoogleProvider from "next-auth/providers/google";
export const authOptions = {
  
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_ID,
      clientSecret: process.env.GOOGLE_SECRET,
    }),

    // ...add more providers here
  ],
};
export default NextAuth(authOptions);

.env.local

GOOGLE_ID=xxx
GOOGLE_SECRET=xxx
NEXTAUTH_URL=http://localhost:3000

组件中调用代码

import { signIn, signOut, useSession } from "next-auth/react";
<div className="link" onClick={signIn}>
    <p>Hello Alex Smith</p>
    <p className="font-extrabold md:text-sm">Account & Lists</p>
</div>

错误详情

  • 点击Google登录按钮后跳转至http://localhost:3000/api/auth/signin/google,返回500内部服务器错误
  • 终端报错:ReferenceError: ReadableStream is not defined

内容的提问来源于stack exchange,提问作者PinPiguin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 18:20:34