From b9071ab2b3295119363a4336ab7b388bf2b33dee Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Wed, 28 Aug 2024 22:45:08 +0400 Subject: [PATCH] Fix: Always remove trailing slashes from SITE_URL --- backend/src/lib/config/env.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts index ca19fd425..f21312311 100644 --- a/backend/src/lib/config/env.ts +++ b/backend/src/lib/config/env.ts @@ -1,6 +1,7 @@ import { Logger } from "pino"; import { z } from "zod"; +import { removeTrailingSlash } from "../fn"; import { zpStr } from "../zod"; export const GITLAB_URL = "https://gitlab.com"; @@ -63,7 +64,9 @@ const envSchema = z .string() .min(32) .default("#5VihU%rbXHcHwWwCot5L3vyPsx$7dWYw^iGk!EJg2bC*f$PD$%KCqx^R@#^LSEf"), - SITE_URL: zpStr(z.string().optional()), + + // Ensure that the SITE_URL never ends with a trailing slash + SITE_URL: zpStr(z.string().transform((val) => (val ? removeTrailingSlash(val) : val))).optional(), // Telemetry TELEMETRY_ENABLED: zodStrBool.default("true"), POSTHOG_HOST: zpStr(z.string().optional().default("https://app.posthog.com")),