Skip to content

Commit cd7a308

Browse files
committed
fix smtp secure env vars
1 parent e0adc2b commit cd7a308

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

apps/webapp/app/env.server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { z } from "zod";
22
import { SecretStoreOptionsSchema } from "./services/secrets/secretStoreOptionsSchema.server";
33
import { isValidDatabaseUrl } from "./utils/db";
44
import { isValidRegex } from "./utils/regex";
5+
import { BoolEnv } from "./utils/boolEnv";
56

67
const EnvironmentSchema = z.object({
78
NODE_ENV: z.union([z.literal("development"), z.literal("production"), z.literal("test")]),
@@ -50,7 +51,7 @@ const EnvironmentSchema = z.object({
5051
RESEND_API_KEY: z.string().optional(),
5152
SMTP_HOST: z.string().optional(),
5253
SMTP_PORT: z.coerce.number().optional(),
53-
SMTP_SECURE: z.coerce.boolean().optional(),
54+
SMTP_SECURE: BoolEnv.optional(),
5455
SMTP_USER: z.string().optional(),
5556
SMTP_PASSWORD: z.string().optional(),
5657

@@ -338,7 +339,7 @@ const EnvironmentSchema = z.object({
338339
ALERT_RESEND_API_KEY: z.string().optional(),
339340
ALERT_SMTP_HOST: z.string().optional(),
340341
ALERT_SMTP_PORT: z.coerce.number().optional(),
341-
ALERT_SMTP_SECURE: z.coerce.boolean().optional(),
342+
ALERT_SMTP_SECURE: BoolEnv.optional(),
342343
ALERT_SMTP_USER: z.string().optional(),
343344
ALERT_SMTP_PASSWORD: z.string().optional(),
344345
ALERT_RATE_LIMITER_EMISSION_INTERVAL: z.coerce.number().int().default(2_500),

apps/webapp/app/utils/boolEnv.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { z } from "zod";
2+
3+
export const BoolEnv = z.preprocess((val) => {
4+
if (typeof val !== "string") {
5+
return val;
6+
}
7+
8+
return ["true", "1"].includes(val.toLowerCase().trim());
9+
}, z.boolean());

0 commit comments

Comments
 (0)