0
In my ASP.NET CORE MVC application I have the dist folder in wwwroot:
According to the documentation Static Files in ASP.NET CORE configured the startup class by adding an http response header:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
// using Microsoft.AspNetCore.Http;
ctx.Context.Response.Headers.Append(
"Access-Control-Allow-Origin", "*");
}
});
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
}
Example (functions.json):
What I’m missing ?
CORS. https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-5.0missing
– Jéf Bueno