我目前正在尝试在我的 NodeJS + React 应用程序中实现 Auth0。 尽管我有一个大问题,但给出的这个教程真的很好而且很有帮助。 每次我尝试通过 Auth0 登录/注册时,我都会得到 p>
XMLHttpRequest cannot load https://XYZ.eu.auth0.com/usernamepassword/login. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
所以我大致了解这意味着什么。但我只是不知道在哪里设置允许这个请求到 Auth0 所需的选项。在服务器端?在浏览器代码中?
最好的问候
编辑: 正如 Rodrigo López Dato 指出的那样,我可以在这里在我的应用程序中编写 Origins:https://manage.auth0.com/#/applications
本地开发时应该放什么?我的 IP?
最佳答案
如果你在本地开发,你可以把你要重定向到的 URL。例如,如果你在 localhost 的 4000 端口上运行,并且你想重定向到名为 /callback
的路由,你可以输入:
http://localhost:4000/callback
在那个领域。
关于node.js - Auth0 和 React 的 CORS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34495297/