Skip to content

Commit 7290e29

Browse files
Fix content-type header for external-dns v0.20.0 compatibility
Strip charset parameter from Content-Type header in proxy to match strict external-dns validation requirements. External-DNS expects exactly 'application/external.dns.webhook+json;version=1' without the charset=utf-8 that Express.js adds automatically.
1 parent ac4c848 commit 7290e29

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

webhook-proxy/proxy.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ function proxyRequest(clientReq, clientRes, targetUrl) {
5252
console.log(`[${clientReq.method}] ${clientReq.url} -> ${url.href}`);
5353

5454
const proxyReq = http.request(options, (proxyRes) => {
55-
// Forward status code and headers
56-
clientRes.writeHead(proxyRes.statusCode, proxyRes.headers);
55+
// Clean up headers - remove charset from content-type for external-dns compatibility
56+
const headers = { ...proxyRes.headers };
57+
if (headers['content-type']) {
58+
// External-DNS expects exactly: application/external.dns.webhook+json;version=1
59+
// Express adds charset which breaks strict validation
60+
headers['content-type'] = headers['content-type'].replace(/;\s*charset=[^;]+/, '');
61+
}
62+
63+
// Forward status code and cleaned headers
64+
clientRes.writeHead(proxyRes.statusCode, headers);
5765

5866
// Pipe response body
5967
proxyRes.pipe(clientRes);

0 commit comments

Comments
 (0)