Clerk验证 – GET http://localhost:3000/ 401 (未经授权) – 登录/登出后的401循环

huangapple go评论57阅读模式
英文:

Clerk Auth - GET http://localhost:3000/ 401 (Unauthorized) - 401 Loop after Signin/Signout

问题

你好,

我一直在尝试在最新版本的Next中使用应用程序路由器设置Clerk。我已经阅读了详细的文档,似乎很容易设置,所以我尝试在我正在进行的新项目上进行了尝试。

我按照Clerk提供的入门说明进行了操作,但没有成功:https://clerk.com/docs/nextjs/get-started-with-nextjs

我遇到的问题是,一旦在登录或注册时经过授权,我会被重定向到我在env.local中设置的路由,但我开始无限循环地收到GET http://localhost:3000/ 401(未经授权)错误。唯一的方法来摆脱这个循环是停止Next服务器或删除Clerk存储的本地存储文件。

我认为我在初始设置中犯了错误,但每次我按照说明进行操作时,我都会一次又一次地遇到相同的问题。

我还尝试运行了Clerk在GitHub上提供的示例 clerkinc/clerk-next-app-router-starter,但我得到了相同的错误。我唯一手动设置的是在.env.local文件中添加API密钥和秘密。

  • 按照Clerk提供的入门说明进行操作
  • 尝试多个浏览器(Firefox/Chrome)
  • 运行clerkinc/clerk-next-app-router-starter存储库示例
  • 创建另一个Clerk应用程序(用户池)

如上所述,一切似乎都按照官方文档进行了设置。我期待着利用一个可以完成大部分繁重工作的身份验证产品。是否有人遇到相同的问题,或者能够推荐我要研究的路径,因为我已经没有任何想法了?

谢谢。

英文:

Good day,

I have been trying to setup Clerk on Next lastest version with the app the App router.

I have went through the well written docs and it seem pretty straighforward to setup so I gave it a shot on a new project I have been working on.

I have followed the get started instructions provided by CLerk without sucess: https://clerk.com/docs/nextjs/get-started-with-nextjs

The issue I'm facing is that once authorized on signin or signup I get redirected to the route I have setup in my env.local as planned, but I start getting on infinite loop of GET http://localhost:3000/ 401 (Unauthorized) error.The only way to get out of that loop is to stop the Next server or delete the localstorage files stored by Clerk

I though that I made mistake in the intial setup but everytimes I go through the instructions I'm facing the same issue over and over again.

I have also tried to run the example provided by Clerk on Github clerkinc/clerk-next-app-router-starter and I get the same error. The only manual settings I performed is adding the API key and Secret in the .env.local file

-Followed the get started instructions provided by CLerk
-Try multiple browser (Firefox/Chrome)
-Run the clerkinc/clerk-next-app-router-starter repository example
-Create another Clerk applications 9user pool)

As mentionned above everythig seem to be setup according to the official docs

I was looking forward to leverage an auth product that do most of the heavy lifting. Anyone facing the same issue or would recommend a path to look into as I'm getting out of idea here?

Thanks

答案1

得分: 2

将以下内容添加到 authMiddleware 中的键值对:

authMiddleware({ debug: true })

这将告诉您是什么导致了 401 错误以及您的应用程序的无限加载。对我来说,原因是 "token-not-active-yet",这是由于我的计算机上设置的时间不正确导致的。

英文:

I just had this issue myself and was able to fix it. Add the following key value to authMiddleware.

authMiddleware({ debug: true })

This will tell you what is causing the 401 and infinite loading for your app. For me, it was the reason was "token-not-active-yet", which was due to incorrect time set on my computer.

huangapple
  • 本文由 发表于 2023年6月8日 11:57:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428521.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定