【问题标题】:ionic: No 'Access-Control-Allow-Origin' header is present on the requested resourceionic:请求的资源上不存在“Access-Control-Allow-Origin”标头
【发布时间】:2015-10-08 12:42:58
【问题描述】:

这是我在研究后发现的允许跨域请求的 ionic.project

{
  "name": "AppName",
  "app_id": "",
  "proxies": [
    {
      "path": "/path",
      "proxyUrl": "http://www.url.com/path"
    }
  ]
}

当我在我的 cmd 终端上运行 ionic serve 时,它​​会启动浏览器并在控制台上得到它

XMLHttpRequest cannot load http://www.url.com/Token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

可能出了什么问题?

【问题讨论】:

    标签: android cordova ionic


    【解决方案1】:

    至于我,我使用这个插件来操作 Content-Security-Policy:

    cordova-plugin-whitelist

    这对我有帮助。

    【讨论】:

    • 我加了好几次,没有结果
    • 您是否在 index.html 中添加了这个?
    • 还有这个 在你的 config.xml
    • 希望对您有所帮助。
    • 这个问题不是 CSP,它与 CORS 有关。
    猜你喜欢
    • 2018-03-09
    • 2013-11-29
    • 2014-07-28
    • 2014-01-19
    • 2013-12-07
    相关资源
    最近更新 更多