Is it possible ti create a web site in IIS7 which somehow could look like it sits in a different domain, so that from one of this site's pages I can test Cross-Origin-Resource-Sharing calls to a WCF service in my local host?
You can test it with any rest client like POSTMAN Rest Client, or simply you can check it from browser console - > Network tab -> in xhr filter - check the header for the particular request. you can check request and response.
1. Use the proxy setting in Create React App. "proxy": "https://cat-fact.herokuapp.com/", Now when you make an API request to https://localhost:3000/api/facts Create React App will proxy the API request to https://cat-fact.herokuapp.com/facts and the CORS error will be resolved.
Having given the concept that CORS does not provide any additional security when talking about API access, this means that that allowing a particular domain like localhost does not make your API less secure.
You can add any domain names you like to your hosts file (%windir%\System32\Drivers\etc\hosts
) and map those back to 127.0.0.1
. Any requests to that domain will then be sent to your local machine.
Each domain name you add should be treated separately so far as CORS is concerned. If you're on a Windows Server SKU, you can even configure IIS to use multiple sites and configure it to examine host headers to determine which site responds to requests for each domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With