diff --git a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs index 9c5062a..43272a2 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs @@ -119,7 +119,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering unencodedAbsoluteUrl, unencodedPathAndQuery, CustomDataParameter, - TimeoutMillisecondsParameter); + TimeoutMillisecondsParameter, + request.PathBase.ToString()); if (!string.IsNullOrEmpty(result.RedirectUrl)) { diff --git a/src/Microsoft.AspNetCore.SpaServices/Prerendering/Prerenderer.cs b/src/Microsoft.AspNetCore.SpaServices/Prerendering/Prerenderer.cs index 8785f34..43c2ed0 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Prerendering/Prerenderer.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Prerendering/Prerenderer.cs @@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering /// The path and query part of the URL of the currently-executing HTTP request. This is supplied to the prerendering code. /// An optional JSON-serializable parameter to be supplied to the prerendering code. /// The maximum duration to wait for prerendering to complete. + /// The PathBase for the currently-executing HTTP request. /// public static Task RenderToString( string applicationBasePath, @@ -38,7 +39,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering string requestAbsoluteUrl, string requestPathAndQuery, object customDataParameter, - int timeoutMilliseconds) + int timeoutMilliseconds, + string requestPathBase) { return nodeServices.InvokeExportAsync( NodeScript.Value.FileName, @@ -48,7 +50,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering requestAbsoluteUrl, requestPathAndQuery, customDataParameter, - timeoutMilliseconds); + timeoutMilliseconds, + requestPathBase); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts index 89deeed..18bcfd3 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts @@ -7,7 +7,7 @@ import { run as domainTaskRun, baseUrl as domainTaskBaseUrl } from 'domain-task/ const defaultTimeoutMilliseconds = 30 * 1000; export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc { - const resultFunc = (callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string, customDataParameter: any, overrideTimeoutMilliseconds: number) => { + const resultFunc = (callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string, customDataParameter: any, overrideTimeoutMilliseconds: number, requestPathBase: string) => { // Prepare a promise that will represent the completion of all domain tasks in this execution context. // The boot code will wait for this before performing its final render. let domainTaskCompletionPromiseResolve; @@ -19,6 +19,7 @@ export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc { location: url.parse(requestPathAndQuery), origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host, url: requestPathAndQuery, + baseUrl: (requestPathBase || '') + '/', absoluteUrl: absoluteRequestUrl, domainTasks: domainTaskCompletionPromise, data: customDataParameter diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts index c919646..e89ec74 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts @@ -23,6 +23,7 @@ interface BootFuncParams { location: any; // e.g., Location object containing information '/some/path' origin: string; // e.g., 'https://example.com:1234' url: string; // e.g., '/some/path' + baseUrl: string; // e.g., '' or '/myVirtualDir' absoluteUrl: string; // e.g., 'https://example.com:1234/some/path' domainTasks: Promise; data: any; // any custom object passed through from .NET