My requests have been blocked by CORS policies, I have the following in my startup class:
services.AddCors(options =>
{
options.AddDefaultPolicy(
builder => {
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
I'm using an Nginx server and I always get the following error when I make a request with my angular app:
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Any help is really appreciated!
Edit
I made some changes suggested in the code, but I got the same error. The changes made were the following:
services.AddCors(options =>
{
options.AddPolicy(
"corsapp",
builder => {
builder
.WithOrigins("https://myurl/", "https://myurl2/")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
And in the Configure method:
app.UseRouting();
app.UseCors("corsapp");
app.UseAuthorization();
myurl and myurl2 are two urls that make requests to the api, both have the same domain, but different subdomain