Open Rob--W opened 7 years ago
My use case for wanting this is to be able to deploy a staging version of a website outside the normal infrastructure. The backend services only support requests from the prod website. I therefore set up a CORS proxy, but I don't want it to be used for anything other than this one purpose.
Any updates on this? I'd much appreciate the ability to block request to the server's local area network, perhaps have it as the default behaviour. Thank you!
The default implementation of CORS Anywhere (server.js) does not restrict the target URLs. The ability to enforce restrictions based on the destination URLs has been requested in #67. Since I am going to add this to improve security, I should also do something with another glaring issue: Normally resources from servers on localhost or a local private network are not really open to the web. CORS Anywhere is designed to allow any website to read public data from any other website (credentials are explicitly stripped). However, information in a private network is likely not supposed to be public information, so such requests should be rejected by default.
Implementation plan
Public API
Support a new option,
dnsLookup
, with the following signature:To get the current behavior (i.e. allow any IP), use the following implementation of
dnsLookup
:Implementation details in CORS Anywhere
proxyOptions.target
in theproxyRequest
function.The implementation can look like this (replacing https://github.com/Rob--W/cors-anywhere/blob/143eff177c7e7d4bf241b83c57dd1e2c6378d53b/lib/cors-anywhere.js#L122-L123). (and also using
location.href
instead oflocation
at https://github.com/Rob--W/cors-anywhere/blob/143eff177c7e7d4bf241b83c57dd1e2c6378d53b/lib/cors-anywhere.js#L87)