parent
ac8f0ebaac
commit
e30adbaac2
|
@ -14,7 +14,7 @@ URL=http://localhost:3000
|
|||
PORT=3000
|
||||
|
||||
# enforce (auto redirect to) https in production, (optional) default is true.
|
||||
# set to false if your SSL is terminated at a loadbalancer, for example
|
||||
# set to false if your SSL is terminated at a loadbalancer, for example
|
||||
FORCE_HTTPS=true
|
||||
|
||||
ENABLE_UPDATES=true
|
||||
|
|
|
@ -23,7 +23,21 @@ const app = new Koa();
|
|||
|
||||
app.use(compress());
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
// Force redirect to HTTPS protocol unless explicitly disabled
|
||||
if (process.env.FORCE_HTTPS !== "false") {
|
||||
app.use(
|
||||
enforceHttps({
|
||||
trustProtoHeader: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
console.warn("Enforced https was disabled with FORCE_HTTPS env variable");
|
||||
}
|
||||
|
||||
// trust header fields set by our proxy. eg X-Forwarded-For
|
||||
app.proxy = true;
|
||||
} else {
|
||||
/* eslint-disable global-require */
|
||||
const convert = require("koa-convert");
|
||||
const webpack = require("webpack");
|
||||
|
@ -72,20 +86,6 @@ if (process.env.NODE_ENV === "development") {
|
|||
app.use(logger());
|
||||
|
||||
app.use(mount("/emails", emails));
|
||||
} else if (process.env.NODE_ENV === "production") {
|
||||
// Force redirect to HTTPS protocol unless explicitly disabled
|
||||
if (process.env.FORCE_HTTPS !== "false") {
|
||||
app.use(
|
||||
enforceHttps({
|
||||
trustProtoHeader: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
console.warn("Enforced https was disabled with FORCE_HTTPS env variable");
|
||||
}
|
||||
|
||||
// trust header fields set by our proxy. eg X-Forwarded-For
|
||||
app.proxy = true;
|
||||
}
|
||||
|
||||
// catch errors in one place, automatically set status and response headers
|
||||
|
|
Reference in New Issue