Refactor BaseUrl and ApiUrl configuration handling.
Updated to use `Http:BaseUrl` for backward compatibility with `Hosting:BaseUrl`. Simplified ApiUrl construction by removing redundant configuration keys and standardizing the behavior using `ApiPrefix`.
This commit is contained in:
parent
07c46ae5a7
commit
406975f64e
|
|
@ -2,8 +2,8 @@
|
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@inject IConfiguration Configuration;
|
||||
@{
|
||||
var baseUrl = Configuration["Hosting:BaseUrl"]!;
|
||||
var apiUrl = Configuration["Hosting:ApiUrl"]!;
|
||||
var baseUrl = Configuration["Hosting:BaseUrl"] ?? Configuration["Http:BaseUrl"]!; // HttpBaseUrl is for backward compatibility.
|
||||
var apiUrl = $"{baseUrl.TrimEnd('/')}/{(Configuration["Hosting:ApiPrefix"] ?? "elsa/api").TrimStart('/')}";
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
|
@ -51,8 +51,7 @@
|
|||
<script src="@baseUrl/_content/Radzen.Blazor/Radzen.Blazor.js"></script>
|
||||
<script>
|
||||
window.getClientConfig = function() { return {
|
||||
"apiUrl": "@apiUrl",
|
||||
"baseUrl": "@baseUrl"
|
||||
"apiUrl": "@apiUrl"
|
||||
} };
|
||||
</script>
|
||||
<script src="@baseUrl/_framework/blazor.webassembly.js"></script>
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ services
|
|||
|
||||
http.ConfigureHttpOptions = options =>
|
||||
{
|
||||
options.BaseUrl = new Uri(configuration["Hosting:BaseUrl"]!);
|
||||
options.BaseUrl = new Uri(configuration["Hosting:BaseUrl"] ?? configuration["Http:BaseUrl"]!); // HttpBaseUrl is for backward compatibility.
|
||||
options.BasePath = configuration["Http:BasePath"];
|
||||
};
|
||||
})
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"DatabaseProvider": "Sqlite",
|
||||
"Hosting": {
|
||||
"BaseUrl": "https://localhost:8080",
|
||||
"ApiUrl": "https://localhost:8080/elsa/api"
|
||||
"ApiPrefix": "/elsa/api"
|
||||
},
|
||||
"Identity": {
|
||||
"Tokens": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue