Skip to content

Commit f13bb8b

Browse files
feat: support setting headers via env
1 parent f17ba61 commit f13bb8b

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
@@ -192,6 +192,18 @@ export class Grid {
192192
this.fetch = options.fetch ?? Shims.getDefaultFetch();
193193
this.#encoder = Opts.FallbackEncoder;
194194

195+
const customHeadersEnv = readEnv('GRID_CUSTOM_HEADERS');
196+
if (customHeadersEnv) {
197+
const parsed: Record<string, string> = {};
198+
for (const line of customHeadersEnv.split('\n')) {
199+
const colon = line.indexOf(':');
200+
if (colon >= 0) {
201+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
202+
}
203+
}
204+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
205+
}
206+
195207
this._options = options;
196208

197209
this.apiKey = apiKey;

0 commit comments

Comments
 (0)