为什么在使用react-stormpath LoginForm组件时收到跨域错误? [英] Why am I receiving a cross-origin error when using the react-stormpath LoginForm component?

查看:71
本文介绍了为什么在使用react-stormpath LoginForm组件时收到跨域错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了 stormapth-sdk -react github仓库以设置基本的登录表单.表单显示出来,但是控制台中的错误立即引起我的注意:

I followed the instructions found in the readme in the stormapth-sdk-react github respository to set up a basic login form. The form displays, but I am immediately greeted by errors in the console:

XMLHttpRequest无法加载https://{redacted} .apps.stormpath.io/me.所请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许访问来源' http://localhost:3000 .响应的HTTP状态码为403.

XMLHttpRequest cannot load https://{redacted}.apps.stormpath.io/me. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 403.

登录端点出现相同的错误.

I get an identical error for the login endpoint.

客户端API指南表示该客户端端点必须配置为允许来自特定域的流量,但不提供有关如何执行此操作的任何说明:

The Client API Guide indicates that client endpoints have to be configured to allow traffic from a particular domain, but does not provide any instructions for how to do this:

使用Client API的应用程序具有两个相关的配置参数,都可以在Stormpath管理控制台的应用程序"页面上找到:...

Applications that use the Client API have two relevant configuration parameters, both found on your Application’s page in the Stormpath Admin Console:...

  1. 授权的回调URI::此列表应包括您的用户在与外部提供商进行身份验证后将返回的所有URI,例如,作为社交登录流程的一部分.例如,如果在启动社交登录流程时未指定重定向URI,则将重定向用户此列表中的第一个URI.
  2. 授权的原始URI: 此列表应包含应用程序的URL,或者发送到客户端API的请求的原始标头中将包含任何URL.
  1. Authorized Callback URIs: This list should include any URIs that your users will be returned to after they have completed authentication with an outside provider, for example as a part of the social login flow. For example, if you do not specify a redirect URI when you kick off the social login flow, the user will be redirected the first URI in this list.
  2. Authorized Origin URIs: This list should include the application’s URL, or whatever URL will be included in the Origin header of requests sent to the Client API.

我需要做什么才能使它正常工作?

What do I need to do to get this working?

推荐答案

要解决此问题,您可以登录到 https://api.stormpath.com ,导航至应用程序">我的应用程序",然后将授权原始URI 修改为包含http://localhost:3000.

To fix this, you can login to https://api.stormpath.com, navigate to Applications > My Application, and modify the Authorized Origin URIs to include http://localhost:3000.

这篇关于为什么在使用react-stormpath LoginForm组件时收到跨域错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆