【问题标题】:Content Security Error in connecting to localhost using EmberJS使用 EmberJS 连接到 localhost 时出现内容安全错误
【发布时间】:2015-09-25 19:00:11
【问题描述】:

我正在连接到 localhost 以使用 json 数据。但是,我收到这些错误,如下所示:

我已经尝试过这里列出的解决方案: Violating Content Security Policy directive after ember-cli 0.0.47 upgrade(在我的 environment.js 中添加 contentSecurityPolicy 字段) 还有http://discuss.emberjs.com/t/help-resolving-error-report-only-refused-to-load-the-script/6902

还有内容安全策略错误。

旁注:它能够成功地从 localhost 获取 json 数据(状态为 200 作为响应)但它无法在 ember 上显示

【问题讨论】:

    标签: ember.js


    【解决方案1】:

    我能够找出导致错误的原因,首先我需要确保在 environment.js 中存储的 contentSecurityPolicy 字段中如下

    contentSecurityPolicy: { 
        ...
        ...
        'connect-src': "'self' 127.0.0.1:8000"
        ...
    }
    

    在服务器 url 上没有引号。对于我遇到的第二个错误,我遵循了这个: https://github.com/ottoyiu/django-cors-headers

    因为我使用相同的端口 - 运行时必然会出现跨源资源使用问题,我需要调整服务器设置以适应相同的源资源。希望对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 2022-01-04
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      • 2015-01-06
      • 2020-03-13
      • 1970-01-01
      • 2016-07-05
      相关资源
      最近更新 更多