❔ WebAPI Cors problem when calling API from Frontend
Hi, I'm having the following code while trying calling my API from Frontend:
Access to XMLHttpRequest at 'http://localhost:5222/api/Users' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
For try to solve this I added a code in the Program.cs
with an exception, but I'm still having the same problem and I don't know in which other way could I solve.
I show you the code of Program.cs
I also tried to move the app.UseCors
between app.UseRouting()
and app.UseAuthorization()
with no results8 Replies
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
bump
@uselessxp I believe you have to call
AddCors
on your serviceshm, I added it but still same error
Have you tried moving it before
UseAuthorization
?
Also have you tried with AllowAnyOrigin
just to see if works or not?yeah actually I did both, and tried to execute with F11, but still not working
Hmm, this happens on all browsers?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.