I'm trying to make an HTTP GET request to my API, and it returns OPTIONS 405 (Method Not Allowed)
and
Access to XMLHttpRequest at 'apiurl' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Below is my code:
const header = new HttpHeaders();
const request_header = header.append('Authorization', this.token.toString());
console.log(request_header.get('Authorization'));
this.urlList = buildUrl('myurl/', {path: 'mypath'});
return this.http.get(this.urlList,{headers: request_header} );
I've tried to do the same in Postman, C# Console App, and in ASP.NET WebForms, it worked perfectly, but in Angular I get the error mentioned above. I have a HTTP GET request for my login also in TypeScript which WORKS PERFECTLY.
**Note: I do not have access to the backend, but based on C# and Postman it works just fine.
UPDATE: Thank you guys, just to let you know I ended up using Flask with angular to make requests and it is brilliant.