Skip to content

Commit

Permalink
archetype-react-app: [minor][bug] Invalid host header fixes (#321)
Browse files Browse the repository at this point in the history
* Invalid host header fixes

* Re-trigger Build

* re-trigger build

* re-trigger build

* Invalid header fixes & code review

* code review

* code review
  • Loading branch information
didi0613 authored and animesh10 committed May 16, 2017
1 parent 801e322 commit 5d70b97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ module.exports = {
devPkg,
devRequire,
webpack: Object.assign({}, {
devHostname: process.env.WEBPACK_HOST || "localhost",
devHostname: process.env.WEBPACK_HOST || process.env.WEBPACK_DEV_HOST || "localhost",
devPort: utils.getInt(process.env.WEBPACK_DEV_PORT, 2992),
testPort: utils.getInt(process.env.WEBPACK_TEST_PORT, 3001),
https: process.env.WEBPACK_DEV_HTTPS,
modulesDirectories: [],
enableBabelPolyfill: false
}, archetypeOptions.webpack),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@ const webpack = require("webpack");
const archetype = require("electrode-archetype-react-app/config/archetype");
const webpackDevReporter = require("../util/webpack-dev-reporter");

const devProtocol = process.env.WEBPACK_DEV_HTTPS ? "https://" : "http://";
const devProtocol = archetype.webpack.https ? "https://" : "http://";

module.exports = function () {
const devServerConfig = {
reporter: webpackDevReporter,
https: Boolean(archetype.webpack.https)
};

if (process.env.WEBPACK_DEV_HOST || process.env.WEBPACK_HOST) {
devServerConfig.public = `${archetype.webpack.devHostname}:${archetype.webpack.devPort}`;
devServerConfig.headers = {
"Access-Control-Allow-Origin": `${devProtocol}${archetype.webpack.devHostname}:${archetype.webpack.devPort}`
};
} else {
devServerConfig.disableHostCheck = true;
devServerConfig.headers = {
"Access-Control-Allow-Origin": "*"
};
}

const config = {
devServer: {
reporter: webpackDevReporter,
https: Boolean(process.env.WEBPACK_DEV_HTTPS)
},
devServer: devServerConfig,
output: {
publicPath: `${devProtocol}${archetype.webpack.devHostname}:${archetype.webpack.devPort}/js/`,
filename: "[name].bundle.dev.js"
Expand Down

0 comments on commit 5d70b97

Please sign in to comment.