Violating Content Security Policy directive after ember-cli 0.0.47 upgrade

前端 未结 2 1849
挽巷
挽巷 2020-12-12 17:49

I upgraded my ember-cli app to 0.0.47 and am now getting a bunch of errors in my browser console related to the content security policy. How do I fix this issue?

<         


        
2条回答
  •  Happy的楠姐
    2020-12-12 18:45

    After reading some docs at http://content-security-policy.com/ and https://github.com/rwjblue/ember-cli-content-security-policy, I added some policies to my config/environment.js file like so:

    module.exports = function(environment) {
      var ENV = {
        contentSecurityPolicy: {
          'default-src': "'none'",
          'script-src': "'self' 'unsafe-inline' 'unsafe-eval' use.typekit.net connect.facebook.net maps.googleapis.com maps.gstatic.com",
          'font-src': "'self' data: use.typekit.net",
          'connect-src': "'self'",
          'img-src': "'self' www.facebook.com p.typekit.net",
          'style-src': "'self' 'unsafe-inline' use.typekit.net",
          'frame-src': "s-static.ak.facebook.com static.ak.facebook.com www.facebook.com"
        },
    
      // ...
    };
    

    This made all the immediate errors go away, but as soon as I started navigating my app, new ones appeared related to S3 media sources.

    I'm sure this works for apps that don't include any external resources, but I've decided to remove ""ember-cli-content-security-policy" from my package.json file.

提交回复
热议问题