aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index afdf4ab3..e21bf52e 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -470,10 +470,11 @@ namespace slskd
private static IServiceCollection ConfigureAspDotNetServices(this IServiceCollection services)
{
services.AddCors(options => options.AddPolicy("AllowAll", builder => builder
+ .SetIsOriginAllowed((host) => true)
.AllowAnyHeader()
.AllowAnyMethod()
- .SetIsOriginAllowed((host) => true)
- .AllowCredentials()));
+ .AllowCredentials()
+ .WithExposedHeaders("X-URL-Base")));
var jwtSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(OptionsAtStartup.Web.Authentication.Jwt.Key));
@@ -603,6 +604,19 @@ namespace slskd
urlBase = urlBase.StartsWith("/") ? urlBase : "/" + urlBase;
app.UsePathBase(urlBase);
+ app.Use((context, next) =>
+ {
+ context.Response.OnStarting(() =>
+ {
+ // the UI needs to be aware of what the URL base is,
+ // so that react-router can use explicit paths.
+ context.Response.Headers.Add("X-URL-Base", urlBase);
+ return Task.CompletedTask;
+ });
+
+ return next();
+ });
+
Log.Information("Using base url {UrlBase}", urlBase);
// remove any errant double forward slashes which may have been introduced by manipulating the path base