🔧 override headers with custom headers

This commit is contained in:
Nate Sesti 2024-05-20 15:24:29 -07:00
parent 75c5e0b5a1
commit e150f7d26f

View file

@ -59,10 +59,14 @@ export function fetchwithRequestOptions(
: new HttpProxyAgent(proxy, agentOptions)
: new protocol.Agent(agentOptions);
const headers: { [key: string]: string } = requestOptions?.headers || {};
let headers: { [key: string]: string } = {};
for (const [key, value] of Object.entries(init?.headers || {})) {
headers[key] = value as string;
}
headers = {
...headers,
...requestOptions?.headers,
};
// Replace localhost with 127.0.0.1
if (url.hostname === "localhost") {