【问题标题】:Ionicview and ionic serve CORSIonicview 和 ionic 服务 CORS
【发布时间】:2018-08-10 12:37:14
【问题描述】:

我的 ionic 应用程序正在连接到 azure 上的 asp.net web api。 API 已经允许所有源访问和 API_KEY 标头。但是我仍然收到消息 “不允许使用原点'http://localhost:8100'。”在离子发球和离子视图上

离子应用程序中的代码

var headers = new Headers();
headers.append('API_KEY', 'X-some-key');
headers.delete("Origin");
let options = new RequestOptions({ headers: headers});
return this.http.get(url, options);

使用 ionic serve 时的请求和响应标头

【问题讨论】:

    标签: asp.net-web-api ionic-framework ionic-view


    【解决方案1】:

    从这里找到答案:CORS enabled but response for preflight has invalid HTTP status code 404 when POSTing JSON

    问题是后端没有 OPTIONS 处理程序,在 web.config 中添加了 OPTIONS 处理程序。

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 2022-08-13
      • 2017-09-10
      • 1970-01-01
      • 2013-11-17
      • 2011-05-27
      • 1970-01-01
      • 2019-06-24
      相关资源
      最近更新 更多