Add UseForwardedHeaders so /install.sh + backend_ws use https/wss behind Traefik
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user