Add UseForwardedHeaders so /install.sh + backend_ws use https/wss behind Traefik

This commit is contained in:
2026-06-11 20:17:46 +00:00
parent 68738e486d
commit a83e9f93de
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -23,10 +23,10 @@ for the Plan 1 implementation steps that produced this code.
```sh
dotnet test # all backend tests
dotnet run --project backend # starts on http://localhost:5000
dotnet run --project backend # starts on http://localhost:5252
```
Hit `http://localhost:5000/health` to verify it's up.
Hit `http://localhost:5252/health` to verify it's up.
## Smoke test against a live deploy
+9
View File
@@ -4,6 +4,7 @@ using backend.Devices;
using backend.Install;
using backend.Pairing;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
@@ -16,6 +17,13 @@ if (Directory.Exists(keysDir))
.SetApplicationName("smart-assistant");
}
builder.Services.Configure<ForwardedHeadersOptions>(opt =>
{
opt.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
opt.KnownNetworks.Clear();
opt.KnownProxies.Clear();
});
builder.Services.AddDbContext<AppDbContext>(opt =>
opt.UseSqlite(builder.Configuration.GetConnectionString("Default")));
@@ -42,6 +50,7 @@ using (var scope = app.Services.CreateScope())
}
}
app.UseForwardedHeaders();
app.UseAuthentication();
app.UseAuthorization();