I need to pass some headers to downloadUrl function but got is ignoring them and file is not downloaded, how do I do this?
I tried with this - overwrite the headers
const downloadURL = async (url, allowLocalIPs, traceId, options) => {
try {
const protectedGot = await getProtectedGot({ allowLocalIPs });
const stream = protectedGot.stream.get(url, {
responseType: "json",
...options,
headers: {
"user-agent":
"Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0",
"accept-encoding": "gzip, deflate, br, zstd",
"upgrade-insecure-requests": "1",
},
});
const { size } = await prepareStream(stream);
return { stream, size };
} catch (err) {
logger.error(err, "controller.url.download.error", traceId);
throw err;
}
};
here when I get error from download I see in logs which means that headers are not passed
headers: {
'user-agent': 'got (https://github.com/sindresorhus/got)',
'accept-encoding': 'gzip, deflate, br'
},