diff --git a/blueprint.yaml b/blueprint.yaml index 53602c26..03c51521 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -32,8 +32,10 @@ proxy-resources: # whitelist-users: # - owen@fossorial.io headers: - - X-Example-Header: example-value - - X-Another-Header: another-value + - name: X-Example-Header + value: example-value + - name: X-Another-Header + value: another-value rules: - action: allow match: ip diff --git a/server/lib/blueprints/proxyResources.ts b/server/lib/blueprints/proxyResources.ts index b8541518..6244fefa 100644 --- a/server/lib/blueprints/proxyResources.ts +++ b/server/lib/blueprints/proxyResources.ts @@ -138,10 +138,8 @@ export async function updateProxyResources( ? true : resourceData.ssl; let headers = ""; - for (const headerObj of resourceData.headers || []) { - for (const [key, value] of Object.entries(headerObj)) { - headers += `${key}: ${value},`; - } + for (const header of resourceData.headers || []) { + headers += `${header.name}: ${header.value},`; } // if there are headers, remove the trailing comma if (headers.endsWith(",")) { diff --git a/server/lib/blueprints/types.ts b/server/lib/blueprints/types.ts index fe360e92..f11ffe1f 100644 --- a/server/lib/blueprints/types.ts +++ b/server/lib/blueprints/types.ts @@ -40,6 +40,11 @@ export const RuleSchema = z.object({ value: z.string() }); +export const HeaderSchema = z.object({ + name: z.string().min(1), + value: z.string().min(1) +}); + // Schema for individual resource export const ResourceSchema = z .object({ @@ -53,7 +58,7 @@ export const ResourceSchema = z auth: AuthSchema.optional(), "host-header": z.string().optional(), "tls-server-name": z.string().optional(), - headers: z.array(z.record(z.string(), z.string())).optional().default([]), + headers: z.array(HeaderSchema).optional().default([]), rules: z.array(RuleSchema).optional().default([]), }) .refine(