Static Files direkt aus Quell-wwwroot laden, Publish-Kopie deaktiviert
- Program.cs: PhysicalFileProvider auf ../../../wwwroot (Fallback auf publish/wwwroot) - Program.cs: No-Cache-Middleware für HTML/JS/CSS - gott.csproj: PublishStaticWebAssets=false, CopyToPublishDirectory=Never für wwwroot - CSS: DB-Explorer-Styling auf CSS-Variablen umgestellt
This commit is contained in:
1 parent
e61f3ef082
commit
e368abced0
3 files changed
+55
-44
No files matched your search
+32
-2
@@ -7,8 +7,10 @@ using Gott.Endpoints;
|
||||
using Gott.Middleware;
|
||||
using Gott.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -113,12 +115,40 @@ builder.Services.AddSingleton<GitHubEventScannerService>();
|
||||
builder.Services.AddHostedService<GitHubEventScannerService>(sp => sp.GetRequiredService<GitHubEventScannerService>());
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// No-cache for static files (mobile browsers love caching too much)
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var path = context.Request.Path.Value ?? "";
|
||||
if (path.EndsWith(".html") || path.EndsWith(".js") || path.EndsWith(".css") || path == "/")
|
||||
{
|
||||
var headers = context.Response.Headers;
|
||||
headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
||||
headers["Pragma"] = "no-cache";
|
||||
headers["Expires"] = "0";
|
||||
}
|
||||
await next();
|
||||
});
|
||||
|
||||
toolService.SetHttpClientFactory(app.Services.GetRequiredService<IHttpClientFactory>());
|
||||
app.Services.GetRequiredService<AnthropicService>().SetTelegramService(app.Services.GetRequiredService<TelegramService>());
|
||||
await app.Services.GetRequiredService<OpenAiService>().LoadModelsAsync();
|
||||
app.UseWebSockets();
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
// wwwroot: Quell-Verzeichnis bevorzugen (Live-Änderungen ohne Publish)
|
||||
var devWwwroot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "wwwroot"));
|
||||
if (Directory.Exists(devWwwroot))
|
||||
{
|
||||
var fileProvider = new PhysicalFileProvider(devWwwroot);
|
||||
app.UseDefaultFiles(new DefaultFilesOptions { FileProvider = fileProvider });
|
||||
app.UseStaticFiles(new StaticFileOptions { FileProvider = fileProvider });
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
}
|
||||
|
||||
app.UseMiddleware<AuthMiddleware>();
|
||||
|
||||
app.MapAuthEndpoints();
|
||||
|
||||
Reference in new issue
Block a user