Skip to content

Commit 0578f47

Browse files
feat: support setting headers via env
1 parent 3e8db1a commit 0578f47

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
@@ -258,6 +258,18 @@ export class Hypeman {
258258
this.fetch = options.fetch ?? Shims.getDefaultFetch();
259259
this.#encoder = Opts.FallbackEncoder;
260260

261+
const customHeadersEnv = readEnv('HYPEMAN_CUSTOM_HEADERS');
262+
if (customHeadersEnv) {
263+
const parsed: Record<string, string> = {};
264+
for (const line of customHeadersEnv.split('\n')) {
265+
const colon = line.indexOf(':');
266+
if (colon >= 0) {
267+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
268+
}
269+
}
270+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
271+
}
272+
261273
this._options = options;
262274

263275
this.apiKey = apiKey;

0 commit comments

Comments
 (0)