Unverified Commit 15b01e62 authored by Imran Salam's avatar Imran Salam Committed by GitHub
Browse files

add protocol option to prod server script (#22)

parent 1eb2d664
Pipeline #15484 failed with stage
in 2 minutes and 55 seconds
......@@ -17,6 +17,7 @@
"start": "npm install --no-save && npm run serve:dev",
"serve:dev": "npm run copy-dotenv && webpack-dev-server --config ./webpack/webpack.config.dev.js",
"serve:prod": "node ./server.js",
"serve:prod:secure": "node ./server.js -p https",
"build": "rimraf ./dist && webpack --config ./webpack/webpack.config.prod.js",
"deploy": "node deploy",
"certify": "node setup-ssl",
......
......@@ -12,16 +12,24 @@ const app = new Koa();
app.use(convert(history()));
app.use(serve(path.join(__dirname, 'dist'), { br: true, gzip: false }));
// const server = https.createServer(
// {
// key: fs.readFileSync('localhost.key'),
// cert: fs.readFileSync('localhost.crt')
// },
// app.callback()
// );
let protocol = 'http';
// server.listen(3000);
if (process.argv[2] === '-p') {
protocol = process.argv[3];
}
app.listen(3000);
if (protocol.toLowerCase() === 'https') {
https
.createServer(
{
key: fs.readFileSync('localhost.key'),
cert: fs.readFileSync('localhost.crt')
},
app.callback()
)
.listen(3000);
} else {
app.listen(3000);
}
console.log('Running on https://localhost:3000');
console.log(`Running on ${protocol}://localhost:3000`);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment