Skip to content

Commit c8a3244

Browse files
feat: support setting headers via env
1 parent fe45683 commit c8a3244

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
@@ -549,6 +549,18 @@ export class Lithic {
549549
this.fetch = options.fetch ?? Shims.getDefaultFetch();
550550
this.#encoder = Opts.FallbackEncoder;
551551

552+
const customHeadersEnv = readEnv('LITHIC_CUSTOM_HEADERS');
553+
if (customHeadersEnv) {
554+
const parsed: Record<string, string> = {};
555+
for (const line of customHeadersEnv.split('\n')) {
556+
const colon = line.indexOf(':');
557+
if (colon >= 0) {
558+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
559+
}
560+
}
561+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
562+
}
563+
552564
this._options = options;
553565

554566
this.apiKey = apiKey;

0 commit comments

Comments
 (0)