Skip to content

Commit de64330

Browse files
feat: support setting headers via env
1 parent e47248a commit de64330

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
@@ -181,6 +181,18 @@ export class SFCNodes {
181181
this.fetch = options.fetch ?? Shims.getDefaultFetch();
182182
this.#encoder = Opts.FallbackEncoder;
183183

184+
const customHeadersEnv = readEnv('SFC_NODES_CUSTOM_HEADERS');
185+
if (customHeadersEnv) {
186+
const parsed: Record<string, string> = {};
187+
for (const line of customHeadersEnv.split('\n')) {
188+
const colon = line.indexOf(':');
189+
if (colon >= 0) {
190+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
191+
}
192+
}
193+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
194+
}
195+
184196
this._options = options;
185197

186198
this.bearerToken = bearerToken;

0 commit comments

Comments
 (0)