fix: allow empty strings for optional envs
This commit is contained in:
@@ -17,8 +17,11 @@ export const env = createEnv({
|
|||||||
BETTER_AUTH_SECRET: z.string(),
|
BETTER_AUTH_SECRET: z.string(),
|
||||||
BETTER_AUTH_TRUSTED_ORIGINS: z
|
BETTER_AUTH_TRUSTED_ORIGINS: z
|
||||||
.string()
|
.string()
|
||||||
.refine((s) =>
|
.transform((s) => (s === "" ? undefined : s))
|
||||||
s.split(",").every((l) => z.string().url().safeParse(l).success),
|
.refine(
|
||||||
|
(s) =>
|
||||||
|
!s ||
|
||||||
|
s.split(",").every((l) => z.string().url().safeParse(l).success),
|
||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
POSTGRES_URL: z.string().url(),
|
POSTGRES_URL: z.string().url(),
|
||||||
@@ -82,11 +85,17 @@ export const env = createEnv({
|
|||||||
NEXT_PUBLIC_STORAGE_DOMAIN: z.string().optional(),
|
NEXT_PUBLIC_STORAGE_DOMAIN: z.string().optional(),
|
||||||
NEXT_PUBLIC_ALLOW_CREDENTIALS: z
|
NEXT_PUBLIC_ALLOW_CREDENTIALS: z
|
||||||
.string()
|
.string()
|
||||||
.refine((s) => s.toLowerCase() === "true" || s.toLowerCase() === "false")
|
.transform((s) => (s === "" ? undefined : s))
|
||||||
|
.refine(
|
||||||
|
(s) => !s || s.toLowerCase() === "true" || s.toLowerCase() === "false",
|
||||||
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
NEXT_PUBLIC_DISABLE_SIGN_UP: z
|
NEXT_PUBLIC_DISABLE_SIGN_UP: z
|
||||||
.string()
|
.string()
|
||||||
.refine((s) => s.toLowerCase() === "true" || s.toLowerCase() === "false")
|
.transform((s) => (s === "" ? undefined : s))
|
||||||
|
.refine(
|
||||||
|
(s) => !s || s.toLowerCase() === "true" || s.toLowerCase() === "false",
|
||||||
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user