Skip to content

Commit 05f9c08

Browse files
committed
fix sample
1 parent 500dbb5 commit 05f9c08

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

samples/WebApp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
app.UseAuthentication();
3737
app.UseAuthorization();
3838

39-
var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") == true ? "log" : "/";
39+
var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") ? "logs/" : "";
4040
app.UseSerilogUi(options => options
4141
.WithHomeUrl("/#Test")
4242
.WithServerSubPath(serverSubPath)
4343
.WithAuthenticationType(AuthenticationType.Jwt)
4444
.WithExpandedDropdownsByDefault()
4545
.EnableAuthorizationOnAppRoutes()
46-
.InjectJavascript($"{serverSubPath}/js/serilog-ui/custom.js")
46+
.InjectJavascript($"/{serverSubPath}js/serilog-ui/custom.js")
4747
);
4848

4949
app.MapControllerRoute(

samples/WebApp/Properties/launchSettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"commandName": "IISExpress",
2424
"launchBrowser": true,
2525
"environmentVariables": {
26-
"ASPNETCORE_ENVIRONMENT": "Development"
26+
"ASPNETCORE_ENVIRONMENT": "Development",
27+
"SerilogUi:AddServerSubPath": "true"
2728
}
2829
}
2930
}

samples/WebApp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"SerilogUi": {
1919
"UserName": "BasicSampleUser",
2020
"Password": "BasicSamplePwd",
21-
"AddServerSubPath": true
21+
"AddServerSubPath": false
2222
},
2323
"Serilog": {
2424
"Using": ["Serilog.Sinks.MongoDB"],

src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private async Task<string> LoadStream(Stream stream, UiOptions options)
6363
options.ShowBrand,
6464
options.HomeUrl,
6565
BlockHomeAccess,
66-
routePrefix = ConstructRoutesPrefix(options),
66+
RoutePrefix = ConstructRoutesPrefix(options),
6767
options.ExpandDropdownsByDefault
6868
};
6969
string encodeAuthOpts = Uri.EscapeDataString(JsonSerializer.Serialize(feOpts, JsonSerializerOptionsFactory.GetDefaultOptions));
@@ -79,11 +79,11 @@ private async Task<string> LoadStream(Stream stream, UiOptions options)
7979
private static string ConstructRoutesPrefix(UiOptions options)
8080
{
8181
var safeHostPath = string.IsNullOrWhiteSpace(options.ServerSubPath) ? "" : options.ServerSubPath;
82-
var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ?
83-
safeHostPath[1..] : safeHostPath;
82+
var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ? safeHostPath[1..] : safeHostPath;
8483
var hostPathWithDivider = !string.IsNullOrWhiteSpace(hostPathWithoutInitialSlash) &&
85-
!hostPathWithoutInitialSlash.EndsWith('/') ?
86-
$"{hostPathWithoutInitialSlash}/" : hostPathWithoutInitialSlash;
84+
!hostPathWithoutInitialSlash.EndsWith('/')
85+
? $"{hostPathWithoutInitialSlash}/"
86+
: hostPathWithoutInitialSlash;
8787

8888
return $"{hostPathWithDivider}{options.RoutePrefix}";
8989
}

0 commit comments

Comments
 (0)