fix(schemas): accept empty-string fingerprint on externalProxy

The External Proxy form offers a "Default" option with value '' for the
uTLS fingerprint dropdown, but UtlsFingerprintSchema.optional() rejects
empty strings (only undefined or a valid enum member). Saving an inbound
with externalProxy rows failed with `expected one of "360"|"chrome"|...`.

Preprocess '' to undefined before the optional enum, matching the existing
pattern used for VmessSecuritySchema.
This commit is contained in:
MHSanaei 2026-05-27 21:22:09 +02:00
parent 66b80fb81b
commit 470efb7a64
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -17,7 +17,10 @@ export const ExternalProxyEntrySchema = z.object({
port: PortSchema.default(443), port: PortSchema.default(443),
remark: z.string().default(''), remark: z.string().default(''),
sni: z.string().optional(), sni: z.string().optional(),
fingerprint: UtlsFingerprintSchema.optional(), fingerprint: z.preprocess(
(val) => (val === '' ? undefined : val),
UtlsFingerprintSchema.optional(),
),
alpn: z.array(AlpnSchema).optional(), alpn: z.array(AlpnSchema).optional(),
}); });
export type ExternalProxyEntry = z.infer<typeof ExternalProxyEntrySchema>; export type ExternalProxyEntry = z.infer<typeof ExternalProxyEntrySchema>;