From 51650f462319e0aca97f59a714a107c814c5dc1f Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Thu, 14 Apr 2016 14:59:41 +0100 Subject: [PATCH] Clean up RC1 bug workaround --- .../ClientApp/components/fetch-data/fetch-data.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts b/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts index ba245e9..b1eec3a 100644 --- a/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts +++ b/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts @@ -9,11 +9,13 @@ export class FetchData { public forecasts: WeatherForecast[]; constructor(http: Http) { + // Workaround for RC1 bug. This can be removed with ASP.NET Core 1.0 RC2. + let isServerSide = typeof window === 'undefined'; + let options: any = isServerSide ? { headers: { Connection: 'keep-alive' } } : null; + // TODO: Switch to relative URL once angular-universal supports them // https://github.com/angular/universal/issues/348 - http.get('http://localhost:5000/api/SampleData/WeatherForecasts', { - headers: { Connection: 'keep-alive' } // Workaround for RC1 bug. TODO: Remove this after updating to RC2 - }).subscribe(result => { + http.get('http://localhost:5000/api/SampleData/WeatherForecasts', options).subscribe(result => { this.forecasts = result.json(); }); }