Update to latest Angular2/angular-universal and use relative URLs in template's HTTP request

This commit is contained in:
SteveSandersonMS
2016-04-21 11:36:27 +01:00
parent 6a325f8cc4
commit a0c47252ca
5 changed files with 17 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "aspnet-prerendering",
"version": "1.0.0",
"version": "1.0.1",
"description": "Helpers for server-side rendering of JavaScript applications in ASP.NET projects. Works in conjunction with the Microsoft.AspNet.SpaServices NuGet package.",
"main": "index.js",
"scripts": {

View File

@@ -19,9 +19,10 @@ export interface BootFunc {
}
export interface BootFuncParams {
location: url.Url;
url: string;
absoluteUrl: string;
location: url.Url; // e.g., Location object containing information '/some/path'
origin: string; // e.g., 'https://example.com:1234'
url: string; // e.g., '/some/path'
absoluteUrl: string; // e.g., 'https://example.com:1234/some/path'
domainTasks: Promise<any>;
}
@@ -44,8 +45,10 @@ export function renderToString(callback: RenderToStringCallback, applicationBase
const domainTaskCompletionPromise = new Promise((resolve, reject) => {
domainTaskCompletionPromiseResolve = resolve;
});
const parsedAbsoluteRequestUrl = url.parse(absoluteRequestUrl);
const params: BootFuncParams = {
location: url.parse(requestPathAndQuery),
origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host,
url: requestPathAndQuery,
absoluteUrl: absoluteRequestUrl,
domainTasks: domainTaskCompletionPromise