Update base URL retrieval to use configuration setting

Replaced hardcoded base URL construction with a configuration-based approach for better management and flexibility. Updated `appsettings.json` to include the new `BaseUrl` setting under the `Hosting` section.
This commit is contained in:
Sipke Schoorstra 2024-09-06 18:40:40 +02:00
parent b8083193bd
commit 5b583f45d6
2 changed files with 2 additions and 1 deletions

View file

@ -2,7 +2,7 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@inject IConfiguration Configuration;
@{
var baseUrl = $"{Request.Scheme}://{Request.Host}";
var baseUrl = Configuration["Hosting:BaseUrl"]!;
var apiUrl = baseUrl + Url.Content("~/elsa/api");
var basePath = Configuration["Hosting:BasePath"]!;
}

View file

@ -18,6 +18,7 @@
"MySql": "Server=localhost;Database=elsa;Uid=user;Pwd=password;"
},
"Hosting": {
"BaseUrl": "https://localhost:5001",
"BasePath": ""
},
"Identity": {