This error has been occurring whenever I am trying to render my signin page using nextAuth.js
- signin.js *
import { getProviders, signIn as SignIntoProvider} from 'next-auth/react'
// Browser...
function signIn({providers}) {
return (
<>
{Object.values(providers).map((provider) => (
<div key={provider.name}>
<button onClick={() => SignIntoProvider(provider.id)}>
Sign in with {provider.name}
</button>
</div>
))}
</>
);
}
// Server side render
export async function getServerSideProps(){
const providers = await getProviders();
return{
props: {
providers,
},
};
}
export default signIn;
- [...nextauth].js*
import NextAuth from "next-auth"
import GoogleProvider from "next-auth/providers/google"
export default NextAuth({
// Configure one or more authentication providers
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
// ...add more providers here
],
pages: {
signIn: '/auth/signin',
}
})
我已将nextAuth url声明为
'NEXTAUTH_URL= http://localhost:3000'
2条答案
按热度按时间0g0grzrc1#
我也遇到了同样的问题。这似乎是“下一个认证”的问题:“^4.3.2”。
我降级到4.3.1版本,错误消失了。在未来需要注意的是,如果你只安装npm,它会安装最新版本的next-auth。
2w3kk1z52#
我通过清除浏览器的会话和cookie来修复,
当我在[... next-auth].ts中更改某些内容时,尝试创建错误页面时出现问题,我无法再登录,它总是将我重定向到auth/error页面,当它尝试获取/auth/session并显示错误
TypeError [ERR_INVALID_URL]: Invalid URL
时,它会以500响应我。即使我重置了我的代码,它仍然以相同的结果响应,尽管我以前从未得到过这个错误。