make user agent header configurable through env variable

This commit is contained in:
Bilal Catic
2020-02-20 21:07:16 +01:00
parent edc6e2bbf7
commit 6791a509d0
3 changed files with 10 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
const nodeFetch = require("node-fetch");
const { USER_AGENT } = require("../config/appConfig");
const fetch = async (url, options = {}) => {
const newOptions = Object.assign({}, options);
if (!newOptions["headers"]) {
newOptions["headers"] = {};
}
newOptions["headers"]["User-Agent"] =
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36";
newOptions["headers"]["User-Agent"] = USER_AGENT;
return nodeFetch(url, newOptions);
};