diff --git a/server/lib/config.ts b/server/lib/config.ts index ca0fbe44..ee6d6c59 100644 --- a/server/lib/config.ts +++ b/server/lib/config.ts @@ -14,12 +14,12 @@ import { passwordSchema } from "@server/auth/passwordSchema"; import stoi from "./stoi"; const portSchema = z.number().positive().gt(0).lte(65535); -const hostnameSchema = z - .string() - .regex( - /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/ - ) - .or(z.literal("localhost")); +// const hostnameSchema = z +// .string() +// .regex( +// /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/ +// ) +// .or(z.literal("localhost")); const getEnvOrYaml = (envVar: string) => (valFromYaml: any) => { return process.env[envVar] ?? valFromYaml; @@ -42,9 +42,10 @@ const configSchema = z.object({ .record( z.string(), z.object({ - base_domain: hostnameSchema.transform((url) => - url.toLowerCase() - ), + base_domain: z + .string() + .nonempty("base_domain must not be empty") + .transform((url) => url.toLowerCase()), cert_resolver: z.string().optional(), prefer_wildcard_cert: z.boolean().optional() }) @@ -68,7 +69,7 @@ const configSchema = z.object({ const envBaseDomain = process.env.APP_BASE_DOMAIN; if (envBaseDomain) { - return hostnameSchema.safeParse(envBaseDomain).success; + return z.string().nonempty().safeParse(envBaseDomain).success; } return true;