From d23592e6a540cc68d1acc681a3b82137e58b8f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Sat, 14 Sep 2024 02:42:01 +0200 Subject: [PATCH] Fix vercel preview environment (#31) --- backend/src/config/environment.config.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/config/environment.config.ts b/backend/src/config/environment.config.ts index 2b7bbce..57b23c5 100644 --- a/backend/src/config/environment.config.ts +++ b/backend/src/config/environment.config.ts @@ -3,9 +3,12 @@ import * as env from 'env-var'; dotenv.config(); +const fallbackToPreviewFrontend = + process.env.VERCEL_ENV === 'preview' || process.env.FORCE_LAMBDA_API === '1'; + export const FRONTEND_CALLBACK = - process.env.VERCEL_ENV === 'preview' || process.env.FORCE_LAMBDA_API === '1' - ? `https://${process.env.VERCEL_BRANCH_URL!}` + !process.env.FRONTEND_CALLBACK && fallbackToPreviewFrontend + ? process.env.VERCEL_BRANCH_URL! : env.get('FRONTEND_CALLBACK').required().asString(); export const JWT_SECRET = env.get('JWT_SECRET').required().asString();