added path variable

This commit is contained in:
2026-10-23 19:38:36 +02:00
parent 19428550ca
commit 0913adaca5
9 changed files with 61 additions and 13 deletions
@@ -10,6 +10,9 @@ var builder = WebApplication.CreateBuilder(args);
var allowedOrigins = (builder.Configuration["ALLOWED_ORIGINS"] ?? "")
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
var hubPath = builder.Configuration["HUB_PATH"] ?? "/hub";
// Optional prefix when the reverse proxy forwards a sub-path without stripping it, e.g. "/server".
// Requests without the prefix keep working.
var pathBase = builder.Configuration["PATH_BASE"] ?? "";
builder.Services.AddCors(options => options.AddDefaultPolicy(policy =>
{
@@ -35,6 +38,11 @@ builder.Services.AddHostedService<MatchRunner>();
var app = builder.Build();
if (!string.IsNullOrWhiteSpace(pathBase))
{
app.UsePathBase(pathBase);
}
app.UseCors();
app.MapGet("/health", () => Results.Ok(new { status = "ok" }));
app.MapHub<GameHub>(hubPath);