I have an ASP .NET application running on .NET Core 6 and ASP .NET Core 6.
I have added some middleware using app.use in order to add some headers.
The problem is that the middleware in not executed when requesting web worker script.
Not sure how much it will help the only error is there because the headers are missing.
Specify a Cross-Origin Embedder Policy to prevent this frame from being blocked
Here is my Program.cs:
RegisterDependencies();
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
app.Use(async (context, next) =>
{
context.Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp");
context.Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin");
await next();
});
// Configure the HTTP request pipeline.
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "GetCursor",
pattern: "Api/GetCursor/{id}/{scale}",
defaults: new { controller = "Api", action = "GetCursor" }
);
app.MapControllerRoute(
name: "API",
pattern: "Api/{action}/{gameId?}",
defaults: new { controller = "Api", action = "{action}"}
);
app.MapControllerRoute(
name: "FEW",
pattern: "{*url}",
defaults: new { controller = "Home", action = "Index" }
);
app.Run();