G
G
GS32019-08-28 15:28:58
Angular
GS3, 2019-08-28 15:28:58

How to allow connection to local angular access to web api, cors policy from browser?

Can't send request to web api. Both projects are local. I am accessing the web api:

return this.http.post('https://localhost:44375/api/ApplicationUser/Register', body);

configured CORS on the server:
app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader().AllowAnyMethod());

I also made settings on the server, based on the Microsoft Documentation . Still the same error
Error:
Access to XMLHttpRequest at 'https://localhost:44375/api/ApplicationUser/Register' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

POST https://localhost:44375/api/ApplicationUser/Register net::ERR_FAILED

From Postman everything is fine, requests pass.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question