MatixYo MatixYo - 9 months ago 95
Ajax Question

Setting XHR header 'Referer' in Chrome app

I want to set header 'Referer' in my Chrome app.
When I do it this way:

xhr.setRequestHeader('Referer', '');

an error shows:

ajax.js:15 Refused to set unsafe header "Referer"

I found an old topic here where someone modified 'Referer' using chrome.webRequest but this extension is not available now in Chrome apps.
Chrome.webRequest isn't working anymore! All topics on SO recommend using it but it's not supported anymore by chrome.
How to change this header?

Xan Xan

While the API is not available to Chrome Apps' own requests, <webview> has a request interface that implements webRequest and allows you to modify requests coming from it.

This way, you can make a "proxy" page that will do XHR's for you, embed it in a webview, and modify its requests. It's an extra hoop, but at least it's possible.