add https env toggle

This commit is contained in:
2020-11-13 21:19:00 +03:00
parent 0ed825a2c6
commit af26241464
3 changed files with 3 additions and 2 deletions

View File

@@ -17,7 +17,6 @@ RUN npm run build
WORKDIR ../
ENV PORT=8080
ENV DATA_DIR=data
ENV TYPEORM_CONNECTION=mariadb
#ENV TYPEORM_HOST=localhost

View File

@@ -18,7 +18,7 @@ export const app = new Koa();
app.use(cors());
app.use(logger());
app.use(bodyParser());
if (config.env === EnvType.production) {
if (config.https) {
app.use(sslify({ resolver: xForwardedProtoResolver }));
}
app.use(

View File

@@ -11,6 +11,7 @@ export interface IConfig {
env: EnvType;
port: number;
jwtSecret: string;
https: boolean;
dbConnectionOptions: ConnectionOptions | null;
}
@@ -19,6 +20,7 @@ const production: IConfig = {
port: parseInt(process.env.PORT, 10) || 3000,
jwtSecret: process.env.JWT_SECRET,
dbConnectionOptions: null,
https: process.env.HTTPS ? process.env.HTTPS === "yes" : false,
};
const development: IConfig = {