Content Security Policy error
イシュー
- Content Security Policy のエラーで、クロスドメイン接続ができない
Refused to connect to 'http://localhost:1337/api/v1/todos' because it violates the following Content Security Policy directive: "connect-src 'self' 'localhost:1337' 'localhost:35729' ws://localhost:35729 ws://0.0.0.0:35729".
参考
Cross origin error · Issue #267 · simplabs/ember-simple-auth · GitHub
The error you're seeing means that the server doesn't support CORS. Whitelisting an origin in Ember Simple Auth's crossOriginWhitelist only makes Ember Simple Auth send the request, the server still needs to respond with the appropriate headers so that the JS in the browser can actually access the response. See here for more info.
- あなたが見ているエラーは、サーバがCORSをサポートしていないことを意味します。
- 送信元をホワイトリストするだけのEmber のシンプルな認証(crossOriginWhitelist)は、Emberのシンプルな認証の要求を送信します。
- サーバーは、まだブラウザでJSが実際に応答にアクセスできるように、適切なヘッダに応答することが必要です。
- 詳細はこちらを参照してください。
- Using CORS - HTML5 Rocks
sails-docs/CORS.md at master · balderdashy/sails-docs · GitHub
sails-docs/sails.config.cors.md at master · balderdashy/sails-docs · GitHub
ember.js - Setting CORS for static files on ember-cli server - Stack Overflow
- HTTP access control (CORS) | MDN
- angularjs - 'Access-Control-Allow-Origin' header contains multiple values - nginx + sails.js - Stack Overflow
- Sails.js | Realtime MVC Framework for Node.js
- angularjs - cross domain configuration issues using nginx, sails and upstart - Stack Overflow
対応方法
- サーバ側で、config/cors.js の allRoutes をtrueに設定するととりあえずはエラーは解消される。(本来はoriginをしぼるべき)
allRoutes: true