node.js - Auth0 和 React 的 CORS 问题

标签 node.js reactjs cors auth0

我目前正在尝试在我的 NodeJS + React 应用程序中实现 Auth0。 尽管我有一个大问题,但给出的这个教程真的很好而且很有帮助。 每次我尝试通过 Auth0 登录/注册时,我都会得到

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/

相关文章:

Javascript 变量未在 ReactJS 组件中存储值

reactjs - 如何覆盖 Material-UI 隐藏组件的样式?

javascript - Webpack devserver 代理无法解决 CORS 问题

javascript - 判断当前环境和请求来源——需要定义变量

c++ - VS2012 node.js 模块 : troubleshooting LNK2005/LNK1169 errors

javascript - 什么时候在 Nodejs 中使用匿名函数?

javascript - 是否可以使用 react.js 将 promise 数据值分配给外部变量

c# - 在 Owin 启动类中指定域

javascript - 如何通过浏览器或服务器验证ssl证书

node.js - 从 Node v6.7.0 升级到 v8.11.1 时性能糟糕