Make templates work with nonempty baseUrls (e.g., IIS virtual directories)

This commit is contained in:
Steve Sanderson
2017-07-11 23:45:25 +01:00
parent bb0727c34c
commit e65ecebac6
31 changed files with 65 additions and 44 deletions

View File

@@ -6,7 +6,7 @@ export class Fetchdata {
public forecasts: WeatherForecast[];
constructor(http: HttpClient) {
http.fetch('/api/SampleData/WeatherForecasts')
http.fetch('api/SampleData/WeatherForecasts')
.then(result => result.json() as Promise<WeatherForecast[]>)
.then(data => {
this.forecasts = data;

View File

@@ -1,5 +1,6 @@
import 'isomorphic-fetch';
import { Aurelia, PLATFORM } from 'aurelia-framework';
import { HttpClient } from 'aurelia-fetch-client';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap';
declare const IS_DEV_BUILD: boolean; // The value is supplied by Webpack during the build
@@ -11,5 +12,10 @@ export function configure(aurelia: Aurelia) {
aurelia.use.developmentLogging();
}
new HttpClient().configure(config => {
const baseUrl = document.getElementsByTagName('base')[0].href;
config.withBaseUrl(baseUrl);
});
aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('app/components/app/app')));
}