move config options to config file, add option to diable frontend

This commit is contained in:
2023-04-19 23:09:38 +02:00
parent dc3a682a77
commit 049f4d75b9
3 changed files with 50 additions and 14 deletions

28
backend/src/config.ts Normal file
View File

@@ -0,0 +1,28 @@
export interface Config {
port: number;
apiBasePath: string;
disableDefaultApiEndpoint: boolean;
trustProxy: string | boolean;
}
export default function appConfig(): Config {
const {
PORT,
BASE_PATH,
TRUST_PROXY,
DISABLE_DEFAULT_API_ENDPOINT,
} = process.env;
let trustProxy: string | boolean = false;
if (TRUST_PROXY == '*') {
trustProxy = true;
}
return {
port: Number(PORT ?? 3000),
apiBasePath: BASE_PATH ?? '',
trustProxy,
disableDefaultApiEndpoint: DISABLE_DEFAULT_API_ENDPOINT == 'true',
};
}