Skip to content

Commit 6573f02

Browse files
feat: support setting headers via env
1 parent c7c3f2f commit 6573f02

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
@@ -208,6 +208,18 @@ export class Arcade {
208208
this.fetch = options.fetch ?? Shims.getDefaultFetch();
209209
this.#encoder = Opts.FallbackEncoder;
210210

211+
const customHeadersEnv = readEnv('ARCADE_CUSTOM_HEADERS');
212+
if (customHeadersEnv) {
213+
const parsed: Record<string, string> = {};
214+
for (const line of customHeadersEnv.split('\n')) {
215+
const colon = line.indexOf(':');
216+
if (colon >= 0) {
217+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
218+
}
219+
}
220+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
221+
}
222+
211223
this._options = options;
212224
this.idempotencyHeader = 'Idempotency-Key';
213225

0 commit comments

Comments
 (0)