Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 0a116ba

Browse files
Prerendering logic supplies PathBase (formatted as baseUrl) to boot logic
1 parent 2b2465a commit 0a116ba

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
119119
unencodedAbsoluteUrl,
120120
unencodedPathAndQuery,
121121
CustomDataParameter,
122-
TimeoutMillisecondsParameter);
122+
TimeoutMillisecondsParameter,
123+
request.PathBase.ToString());
123124

124125
if (!string.IsNullOrEmpty(result.RedirectUrl))
125126
{

src/Microsoft.AspNetCore.SpaServices/Prerendering/Prerenderer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static Prerenderer()
3030
/// <param name="requestPathAndQuery">The path and query part of the URL of the currently-executing HTTP request. This is supplied to the prerendering code.</param>
3131
/// <param name="customDataParameter">An optional JSON-serializable parameter to be supplied to the prerendering code.</param>
3232
/// <param name="timeoutMilliseconds">The maximum duration to wait for prerendering to complete.</param>
33+
/// <param name="requestPathBase">The PathBase for the currently-executing HTTP request.</param>
3334
/// <returns></returns>
3435
public static Task<RenderToStringResult> RenderToString(
3536
string applicationBasePath,
@@ -38,7 +39,8 @@ public static Task<RenderToStringResult> RenderToString(
3839
string requestAbsoluteUrl,
3940
string requestPathAndQuery,
4041
object customDataParameter,
41-
int timeoutMilliseconds)
42+
int timeoutMilliseconds,
43+
string requestPathBase)
4244
{
4345
return nodeServices.InvokeExportAsync<RenderToStringResult>(
4446
NodeScript.Value.FileName,
@@ -48,7 +50,8 @@ public static Task<RenderToStringResult> RenderToString(
4850
requestAbsoluteUrl,
4951
requestPathAndQuery,
5052
customDataParameter,
51-
timeoutMilliseconds);
53+
timeoutMilliseconds,
54+
requestPathBase);
5255
}
5356
}
5457
}

src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { run as domainTaskRun, baseUrl as domainTaskBaseUrl } from 'domain-task/
77
const defaultTimeoutMilliseconds = 30 * 1000;
88

99
export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
10-
const resultFunc = (callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string, customDataParameter: any, overrideTimeoutMilliseconds: number) => {
10+
const resultFunc = (callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string, customDataParameter: any, overrideTimeoutMilliseconds: number, requestPathBase: string) => {
1111
// Prepare a promise that will represent the completion of all domain tasks in this execution context.
1212
// The boot code will wait for this before performing its final render.
1313
let domainTaskCompletionPromiseResolve;
@@ -19,6 +19,7 @@ export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
1919
location: url.parse(requestPathAndQuery),
2020
origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host,
2121
url: requestPathAndQuery,
22+
baseUrl: (requestPathBase || '') + '/',
2223
absoluteUrl: absoluteRequestUrl,
2324
domainTasks: domainTaskCompletionPromise,
2425
data: customDataParameter

src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface BootFuncParams {
2323
location: any; // e.g., Location object containing information '/some/path'
2424
origin: string; // e.g., 'https://example.com:1234'
2525
url: string; // e.g., '/some/path'
26+
baseUrl: string; // e.g., '' or '/myVirtualDir'
2627
absoluteUrl: string; // e.g., 'https://example.com:1234/some/path'
2728
domainTasks: Promise<any>;
2829
data: any; // any custom object passed through from .NET

0 commit comments

Comments
 (0)