There's a public API that gives a response when directly hit from the browser. I am using Chrome browser. Below is the API - https://query1.finance.yahoo.com/v7/finance/chart/abc?range=7d&interval=1m
When I hit the same API from angular, it gives me below error -
Access to XMLHttpRequest at 'https://query1.finance.yahoo.com/v7/finance/chart/?range=7d&interval=1m' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Below is my code -
this._http.get(url).subscribe(
(resp) => {
console.log(resp);
},
(error) => {
console.log(error);
}
);
There's a solution proposed to use the following command - chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security. It works, but I want a solution that works with a normal browser. Because once I host this, general users obviously won't use that command.