Hi @Caroline Henning ,
Thanks for reaching out.
Here bad request can be due to 'Access-Control-Allow-Origin' header is not set. To allow specific headers to be sent in a CORS request, call WithHeaders and specify the allowed headers:
builder =>
{
builder.WithOrigins("http://contoso.com")
.WithHeaders(HeaderNames.ContentType, "x-custom-header");
});
Also, You can enable CORS through different ways in ASP.net application as disabling the CORS is not recommended for security reasons.
1.Using a default policy in middleware
2.With endpoint routing, CORS can be enabled on a per-endpoint basis using the RequireCors() in the middleware as
3.With the [EnableCors] attribute in the controller class or controller action method as
Ref : Enable CORS in ASP.NET application
Thanks,
Shweta
Please remember to "Accept Answer" if answer helped you.