Skip to content

Commit 36cf10a

Browse files
feat: support setting headers via env
1 parent 1a5051c commit 36cf10a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ export class Orb extends Core.APIClient {
338338
fetch: options.fetch,
339339
});
340340

341+
const customHeadersEnv = Core.readEnv('ORB_CUSTOM_HEADERS');
342+
if (customHeadersEnv) {
343+
const parsed: Record<string, string> = {};
344+
for (const line of customHeadersEnv.split('\n')) {
345+
const colon = line.indexOf(':');
346+
if (colon >= 0) {
347+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
348+
}
349+
}
350+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
351+
}
352+
341353
this._options = options;
342354
this.idempotencyHeader = 'Idempotency-Key';
343355

0 commit comments

Comments
 (0)