Im using ReactJS and Net Core as backend. As soon as I put up a request via to my Net Core, I was responded with a message http://localhost:8080/auth/someendpoint' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've set my Startup.cs:
//Add CORS
//for development env
services.AddCors(options =>
{
options.AddPolicy("AllowAnyOrigin",
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
and use it like:
app.UseCors("AllowAnyOrigin");
Update: finally fixed it, seems like this happens because im trying to use a custom header on my request, i deleted it and it works