Open benzata opened 4 years ago
Yes, if you use CORS Anywhere as a server-side library, then you can use the setHeaders
option to add request headers.
Documentation: https://github.com/Rob--W/cors-anywhere#server Example: https://github.com/Rob--W/cors-anywhere/blob/4814647a9d21f14858da282387a4295c17f2851d/test/test.js#L818-L847
Amazing! Thank you very much for the prompt reply!
Hi, can i also specify Headers that will only be sent if for example a domain rule is met?
Do you mean request headers or response headers?
In either case, CORS Anywhere does not have out-of-the-box support for domain-specific headers (request headers / response headers). If you want to change the (request/response) headers based on the requested URL only, then you could use a different http(s) server in front of CORS Anywhere (example) and directly modify request.headers
(for request headers) or use response.setHeader
(for response headers).
Yes, if you use CORS Anywhere as a server-side library, then you can use the
setHeaders
option to add request headers.Documentation: https://github.com/Rob--W/cors-anywhere#server Example: https://github.com/Rob--W/cors-anywhere/blob/4814647a9d21f14858da282387a4295c17f2851d/test/test.js#L818-L847
I tried to use setHeaders in the server for the "origin" and "referer' headers, but they seem not to change as they are both still https://localhost:port instead of the ones I defined. Is there a way to manipulate these two headers to specify a target of my choice, instead of showing the localhost server domain?
Thank you.
I tried to use setHeaders in the server for the "origin" and "referer' headers, but they seem not to change as they are both still https://localhost:port instead of the ones I defined. Is there a way to manipulate these two headers to specify a target of my choice, instead of showing the localhost server domain?
The option should work. How are you setting the option, and how do you know that the headers aren't changing?
I look at the headers in Firefox Developer->Network for a specific javascript to be downloaded for the page to work. I go to http://ip:8080/http://locaton.com and here is what I see in the Developer:
I set the option as follows:
cors_proxy.createServer({
...
...
...
setHeaders: {"referer": "https://desiredwebsite.com/stuff", "origin" : "https://desiredwebsite.com/stuff"},
...
...
...
}).listen(port, host, function() {
console.log('Running CORS Anywhere on ' + host + ':' + port);
});
Any help is much apprecaited.
Thanks.
Is it possible to add your header for GET requests inside the CORS-Anywhere PROXY? Instead of putting in the header of the GET request in the app code? Thank you very much in advance!!