I am working with cors-anywhere on my localhost. I have the following server.js file...
var host = process.env.HOST || '0.0.0.0';
var port = process.env.PORT || 1234;
var cors_proxy = require('cors-anywhere');
cors_proxy.createServer({
httpProxyOptions: {
secure: false
}
}).listen(port, host, function() {
console.log('listening...');
});
This works and is proxying the initial request when going to:
http://localhost:1234/https://proxy-domain/page
The issue is that on the page I am browsing/being proxied to there are dependent files (i.e., css, javascript, images, etc) that are not being loaded because they are not being proxied appropriately. Looking at my browsers network tab the dependent files are trying to be downloaded from...
http://localhost:12345/sample-image.gif
Really the url should be...
https://proxy-domain/sample-image.gif
How can I configure cors-anywhere to proxy all subsequent requests to the appropriate target url?
According to the documentation you can set
redirectSameOrigin
totrue
, which will redirect requests to the same origin instead of proxying them.