Add ability to include custom headers with requests (#2273)
* Add ability to include custom headers with requests * feedback review * Feedback review
This commit is contained in:
parent
5e13bc2f7c
commit
729d69a541
2 changed files with 16 additions and 2 deletions
|
|
@ -36,12 +36,24 @@ Client4.doFetchWithResponse = async (url, options) => {
|
|||
};
|
||||
}
|
||||
|
||||
const customHeaders = LocalConfig.CustomRequestHeaders;
|
||||
let requestOptions = Client4.getOptions(options);
|
||||
if (customHeaders && Object.keys(customHeaders).length > 0) {
|
||||
requestOptions = {
|
||||
...requestOptions,
|
||||
headers: {
|
||||
...requestOptions.headers,
|
||||
...LocalConfig.CustomRequestHeaders,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
let response;
|
||||
let headers;
|
||||
|
||||
let data;
|
||||
try {
|
||||
response = await fetch(url, Client4.getOptions(options));
|
||||
response = await fetch(url, requestOptions);
|
||||
headers = response.headers;
|
||||
if (!url.startsWith('https') && response.rnfbRespInfo && response.rnfbRespInfo.redirects && response.rnfbRespInfo.redirects.length > 1) {
|
||||
handleRedirectProtocol(url, response);
|
||||
|
|
|
|||
|
|
@ -41,5 +41,7 @@
|
|||
|
||||
"AppGroupId": "group.com.mattermost.rnbeta",
|
||||
|
||||
"ShowSentryDebugOptions": false
|
||||
"ShowSentryDebugOptions": false,
|
||||
|
||||
"CustomRequestHeaders": {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue