add option to set TLS Server Name

This commit is contained in:
Matthias Palmetshofer 2025-04-09 23:42:50 +02:00
parent 0450f62108
commit 674316aa46
No known key found for this signature in database
6 changed files with 84 additions and 11 deletions

View file

@ -16,7 +16,7 @@ import createHttpError from "http-errors";
import logger from "@server/logger";
import { fromError } from "zod-validation-error";
import config from "@server/lib/config";
import { subdomainSchema } from "@server/lib/schemas";
import { subdomainSchema, tlsNameSchema } from "@server/lib/schemas";
const updateResourceParamsSchema = z
.object({
@ -40,7 +40,8 @@ const updateHttpResourceBodySchema = z
isBaseDomain: z.boolean().optional(),
applyRules: z.boolean().optional(),
domainId: z.string().optional(),
enabled: z.boolean().optional()
enabled: z.boolean().optional(),
tlsServerName: z.string().optional()
})
.strict()
.refine((data) => Object.keys(data).length > 0, {
@ -67,6 +68,15 @@ const updateHttpResourceBodySchema = z
{
message: "Base domain resources are not allowed"
}
)
.refine(
(data) => {
if (data.tlsServerName) {
return tlsNameSchema.safeParse(data.tlsServerName).success;
}
return true;
},
{ message: "Invalid TLS Server Name. Use domain name format, or save empty to remove the TLS Server Name." }
);
export type UpdateResourceResponse = Resource;