I wanted to try out some Angular code against a demo odata service, but when requesting data from another domain in a web browser (the angular context) you might get:
Access to XMLHttpRequest at ‘http://services.odata.org/V4/OData/OData.svc/Products?$format=json’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.
To get around this problem you could use a node proxy like this one:
Source: cors-proxy-server – npm
Install and start it up. Now we can call the odata service by prepending the proxy url before the actual api endpoint like this:
Notice the double http://
The entire CORS problem can be summarized like this:
More info regarding CORS here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS