Use <base> to enable relative paths in WebSPA
This commit is contained in:
parent
1efa555825
commit
ed87b6b845
@ -7,6 +7,7 @@ namespace eShopOnContainers.WebSPA
|
||||
{
|
||||
public class AppSettings
|
||||
{
|
||||
public string BaseUrl { get; set; }
|
||||
public string CatalogUrl { get; set; }
|
||||
public string OrderingUrl { get; set; }
|
||||
public string IdentityUrl { get; set; }
|
||||
|
@ -22,7 +22,8 @@ export class ConfigurationService {
|
||||
constructor(private http: Http, private storageService: StorageService) { }
|
||||
|
||||
load() {
|
||||
let url = "/Home/Configuration";
|
||||
const baseURI = document.baseURI.endsWith('/') ? document.baseURI : `${document.baseURI}/`;
|
||||
let url = `${baseURI}Home/Configuration`;
|
||||
this.http.get(url).subscribe((response: Response) => {
|
||||
console.log('server settings loaded');
|
||||
this.serverSettings = response.json();
|
||||
|
@ -22,6 +22,7 @@ namespace eShopConContainers.WebSPA.Server.Controllers
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.HashedMain = GetHashedMainDotJs();
|
||||
ViewBag.BaseUrl = _settings.Value.BaseUrl;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ namespace eShopConContainers.WebSPA
|
||||
}
|
||||
|
||||
Configuration = builder.Build();
|
||||
|
||||
var localPath = new Uri(Configuration["ASPNETCORE_URLS"])?.LocalPath ?? "/";
|
||||
Configuration["BaseUrl"] = localPath;
|
||||
}
|
||||
|
||||
public static IConfigurationRoot Configuration { get; set;}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>eShopConContainers.WebSPA</title>
|
||||
<base href="/" />
|
||||
<base href=@ViewBag.BaseUrl />
|
||||
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user