Skip to content

Commit

Permalink
Fix development config
Browse files Browse the repository at this point in the history
Moved development config out of addon configuration path and into express middleware path. It was getting stomped in some circumstances.
  • Loading branch information
ZebraFlesh committed May 3, 2015
1 parent 79ea585 commit b851c05
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
name: 'ember-cli-content-security-policy',

config: function(environment /*, appConfig */) {
var ENV = {
config: function(/*environment, appConfig */) {
return {
contentSecurityPolicyHeader: 'Content-Security-Policy-Report-Only',
contentSecurityPolicy: {
'default-src': "'none'",
Expand All @@ -14,12 +14,6 @@ module.exports = {
'media-src': "'self'"
}
};

if (environment === 'development') {
ENV.contentSecurityPolicy['script-src'] = ENV.contentSecurityPolicy['script-src'] + " 'unsafe-eval'";
}

return ENV;
},

serverMiddleware: function(config) {
Expand All @@ -33,6 +27,10 @@ module.exports = {
var header = appConfig.contentSecurityPolicyHeader;
var headerConfig = appConfig.contentSecurityPolicy;

if (options.environment === 'development') {
headerConfig['script-src'] = headerConfig['script-src'] + " 'unsafe-eval'";
}

if (options.liveReload) {
['localhost', '0.0.0.0'].forEach(function(host) {
headerConfig['connect-src'] = headerConfig['connect-src'] + ' ws://' + host + ':' + options.liveReloadPort;
Expand Down

0 comments on commit b851c05

Please sign in to comment.