edandersen / core-admin

Fully automatic admin site CRUD UI generator for ASP.NET Core and .NET 8
Other
599 stars 111 forks source link

404 on all static files as soon as authorization is required #109

Open chaelli opened 4 months ago

chaelli commented 4 months ago

I have a very strange behavior. As soon as I am not on "Development" I get 404s on all static files image

I added app.UseCoreAdminCustomAuth((serviceProvider) => Task.FromResult(true)); to make sure I am always authenticated. But still, the issue happens. my program.cs looks like this:

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddJsonFile("appsettings.local.json", optional: true, reloadOnChange: true);
builder.Configuration.AddEnvironmentVariables();

builder.Services.AddHttpContextAccessor();
builder.Services.AddServices();
builder.Services.AddControllers();

builder.Services.AddDbContext<MyDbContext>(option =>
    option.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

// add core admin
builder.Services.AddCoreAdmin();

var app = builder.Build();

app.UseStaticFiles();
app.UseAuthorization();
app.MapControllers();
app.MapDefaultControllerRoute();
app.UseCoreAdminCustomAuth((serviceProvider) => Task.FromResult(true));
app.Run();