reactjs - 我使用谷歌登录在我的 NextJs 应用程序中得到 http://localhost:3000/api/auth/error。为什么?
问题描述
这是我的 [...nextauth].js 文件...
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
export default NextAuth({
providers: [
Providers.Google({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
}),
],
});
这是我要传递登录功能的标题组件...
import { signIn, signOut, useSession } from "next-auth/client";
function Header() {
return(
<div onClick={signIn}>
<p>Sign In</p>
</div>
)
当我点击它时,它会返回一个 404 响应,但我应该在下面看到:
我错过了什么?
解决方案
I got the blunder. It was in my file naming. It is supposed to be pages/api/auth not pages/api/Auth. Fix that and it will work. This is for anyone else who will find themselves in this small bug.
推荐阅读
- node.js - Socket.io 中间件
- javascript - 为什么我会得到“引用前一个状态时在 setState 中使用回调”?
- amazon-web-services - redshift 中是否有任何系统表可以提供我创建的库对象的所有属性
- reactjs - React Link更改URL但仅在单击下拉菜单中的列表项时渲染一次组件
- postgresql - 我的查询没有获取创建的索引
- google-chrome-extension - 弹出菜单未打开
- php - 如何监听 Trait 中所有可用的 Laravel 模型事件
- function - Haskell 对水平线感到困惑
- c - 如何使用C中的护士从下到上而不是从上到下画线
- c++ - 矩形上的最小切割以制成正方形