From 3629cbb87d3ebde433cc6a2b6beeea4c18148921 Mon Sep 17 00:00:00 2001 From: Geoffroy Empain Date: Tue, 8 Dec 2020 21:02:40 +0100 Subject: [PATCH] feat: option to disable caddy config for ui/api --- src/caddy/generate-config.ts | 6 ++++-- src/env.ts | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/caddy/generate-config.ts b/src/caddy/generate-config.ts index 506e685..becd469 100644 --- a/src/caddy/generate-config.ts +++ b/src/caddy/generate-config.ts @@ -32,8 +32,10 @@ export async function generateConfig(): Promise { sites: { listen: sslDisabled ? [':80'] : [':443'], routes: [ - apiRoute, - uiRoute, + ...(env.MELI_STANDALONE ? [] : [ + apiRoute, + uiRoute, + ]), ...sites.flatMap(generateSiteRoutes), fallback, ], diff --git a/src/env.ts b/src/env.ts index 3e645be..a795aa5 100644 --- a/src/env.ts +++ b/src/env.ts @@ -17,6 +17,7 @@ export interface Env { MELI_UI_URL: string; MELI_UI_URL_INTERNAL: string; MELI_SITES_URL: string; + MELI_STANDALONE: boolean; MELI_UI_DIR: string; MELI_JWT_SECRET: string; MELI_JWT_TOKEN_EXPIRATION: number; @@ -98,6 +99,10 @@ const envSpec: EnvSpec = { MELI_SITES_URL: { schema: string().optional().custom(isUrl).default(process.env.MELI_URL || null), }, + MELI_STANDALONE: { + transform: stringToBoolean(), + schema: boolean().optional().default(false), + }, MELI_UI_DIR: { schema: string().optional(), },