I have been attempting to include an IP address in the X-Forwarded-For parameter within the requestHeader, but my code does not seem to be working based on the examples provided in the Chrome API.
Below is the code snippet I am currently using:
var requestFilter = {
urls: [ "<all_urls>" ]
},
extraInfoSpec = ['requestHeaders', 'blocking'],
handler = function( details ) {
var headers = details.requestHeaders,
blockingResponse = {};
var isXForwardedForSet = false;
for (var i = 0, l = headers.length; i < l; ++i) {
if (headers[i].name === 'X-Forwarded-For') {
headers[i].value = "42.104.0.0";
isXForwardedForSet = true;
break;
}
}
if (!isXForwardedForSet) {
headers.push({
name: "X-Forwarded-For",
value: "42.104.0.0"
});
}
blockingResponse.requestHeaders = headers;
return blockingResponse;
};
chrome.webRequest.onBeforeSendHeaders.addListener( handler, requestFilter, extraInfoSpec );