Skip to content

Commit

Permalink
Fix cors for production (security)
Browse files Browse the repository at this point in the history
fix cors and re-added `postinstall` to package.json
  • Loading branch information
Dindaleon committed Jan 1, 2016
1 parent 58f46db commit fac32ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dev": "SET NODE_ENV=development&& npm run start-dev",
"prod": "SET NODE_ENV=production&& SET PORT=8080&& SET WSPORT=8000&& npm start",
"build": "rimraf ./static/assets && webpack -p --progress --stats --config ./webpack/prod.config.js",
"postinstall": "npm run build",
"eslint": "eslint .",
"jscs": "jscs .",
"coveralls": "copy coverage/lcovonly/lcov.info | node ./node_modules/coveralls/bin/coveralls"
Expand Down
13 changes: 11 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ export default function( callback ) {
// Create the Walmart Labs Hapi Server
const server = new Hapi.Server(); // No debug no production
// Configure connections
server.connection({ host: SERVER_HOST, port: SERVER_PORT, labels: [ 'api' ], routes: { cors: true }});
server.connection({ host: SERVER_HOST, port: WS_PORT, labels: [ 'ws' ], routes: { cors: true }});
server.connection({
host: SERVER_HOST,
port: SERVER_PORT,
labels: [ 'api' ],
routes: {
cors: {
origin: [ 'http://' + SERVER_HOST + ':' + WS_PORT ]
}
}
});
server.connection({ host: SERVER_HOST, port: WS_PORT, labels: [ 'ws' ] });

// Set names for each connection
server.connections[0].name = 'API';
Expand Down

0 comments on commit fac32ee

Please sign in to comment.