From an ASP .NET Core web app I am trying to make a call to a Drupal web api using React.js, however I get the following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[my-drupal-api]' is therefore not allowed access.
I have tried adding the following to my Startup.cs:
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
app.UseCors("CorsPolicy");
and I still get the same error.
I am curious if there is another way to do this server-side, without react. Is there way a way to do an asynchronous partial view that will load the data returned from the Drupal web api, without delaying the load of the rest of the page?
Thanks!