I'm facing an issue with my API when making an HTTP GET request - it returns OPTIONS 405 (Method Not Allowed)
.
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.
Here is the code snippet:
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 tested the same request in Postman, C# Console App, and ASP.NET WebForms with success, but it's not working in Angular as I'm getting the error mentioned above. However, my login HTTP GET request in TypeScript is working perfectly.
**Note: I do not have access to the backend, but based on C# and Postman it works just fine.
UPDATE: Thank you, everyone. I have now integrated Flask with Angular for making requests, and it's working brilliantly.