Skip to content

Commit 1a5897b

Browse files
feat: support setting headers via env
1 parent 98c6a4b commit 1a5897b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,18 @@ export class Kernel {
328328
});
329329
this.#encoder = Opts.FallbackEncoder;
330330

331+
const customHeadersEnv = readEnv('KERNEL_CUSTOM_HEADERS');
332+
if (customHeadersEnv) {
333+
const parsed: Record<string, string> = {};
334+
for (const line of customHeadersEnv.split('\n')) {
335+
const colon = line.indexOf(':');
336+
if (colon >= 0) {
337+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
338+
}
339+
}
340+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
341+
}
342+
331343
this._options = options;
332344

333345
this.apiKey = apiKey;

0 commit comments

Comments
 (0)