Из -за этих проблем, я, наверняка, я не знаю. /> Я пытаюсь отключить CSP или хотя бы немного расслабить ограничения, если режим отладки. Но я не могу! < /P>
Я добавил это в свой index.html, чтобы разрешить все: < /p>
Код: Выделить всё
< /code>
и это на стороне сервера (Program.cs), чтобы убедиться, что настройки моего клиента не переоценены. < /p>
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("ApplicationDbContextConnectionPRD")
?? throw new InvalidOperationException("Connection string 'ApplicationDbContextConnection' not found.");
#if DEBUG
connectionString = builder.Configuration.GetConnectionString("ApplicationDbContextConnectionDEV")
?? throw new InvalidOperationException("Connection string 'ApplicationDbContextConnection' not found.");
#endif
builder.Services.AddDbContext(options => options.UseSqlServer(connectionString));
builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true)
.AddRoles()
.AddEntityFrameworkStores();
builder.Services.AddIdentityServer()
.AddApiAuthorization();
builder.Services.AddAuthentication()
.AddIdentityServerJwt();
builder.Services.AddControllersWithViews();
builder.Services.AddRazorPages();
builder.Services.AddSingleton();
builder.Services.AddSignalR();
builder.Services.AddCors(options =>
{
options.AddPolicy(name: "cors",
policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyMethod();
policy.AllowAnyHeader().WithExposedHeaders("*");
});
});
builder.Services.AddHttpClient();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
app.MapHub(BlazorWasmApp.Server.Hubs.ServerHub.HubUrl);
app.MapFallbackToFile("index.html");
app.Use(async (context, next) =>
{
context.Response.Headers.Remove("Content-Security-Policy");
await next.Invoke();
});
app.Run();
Подробнее здесь: https://stackoverflow.com/questions/779 ... t-wasm-app