mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Prerendering logic supplies PathBase (formatted as baseUrl) to boot logic
This commit is contained in:
@@ -119,7 +119,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
unencodedAbsoluteUrl,
|
unencodedAbsoluteUrl,
|
||||||
unencodedPathAndQuery,
|
unencodedPathAndQuery,
|
||||||
CustomDataParameter,
|
CustomDataParameter,
|
||||||
TimeoutMillisecondsParameter);
|
TimeoutMillisecondsParameter,
|
||||||
|
request.PathBase.ToString());
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.RedirectUrl))
|
if (!string.IsNullOrEmpty(result.RedirectUrl))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
/// <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>
|
/// <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>
|
||||||
/// <param name="customDataParameter">An optional JSON-serializable parameter to be supplied to the prerendering code.</param>
|
/// <param name="customDataParameter">An optional JSON-serializable parameter to be supplied to the prerendering code.</param>
|
||||||
/// <param name="timeoutMilliseconds">The maximum duration to wait for prerendering to complete.</param>
|
/// <param name="timeoutMilliseconds">The maximum duration to wait for prerendering to complete.</param>
|
||||||
|
/// <param name="requestPathBase">The PathBase for the currently-executing HTTP request.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<RenderToStringResult> RenderToString(
|
public static Task<RenderToStringResult> RenderToString(
|
||||||
string applicationBasePath,
|
string applicationBasePath,
|
||||||
@@ -38,7 +39,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
string requestAbsoluteUrl,
|
string requestAbsoluteUrl,
|
||||||
string requestPathAndQuery,
|
string requestPathAndQuery,
|
||||||
object customDataParameter,
|
object customDataParameter,
|
||||||
int timeoutMilliseconds)
|
int timeoutMilliseconds,
|
||||||
|
string requestPathBase)
|
||||||
{
|
{
|
||||||
return nodeServices.InvokeExportAsync<RenderToStringResult>(
|
return nodeServices.InvokeExportAsync<RenderToStringResult>(
|
||||||
NodeScript.Value.FileName,
|
NodeScript.Value.FileName,
|
||||||
@@ -48,7 +50,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
requestAbsoluteUrl,
|
requestAbsoluteUrl,
|
||||||
requestPathAndQuery,
|
requestPathAndQuery,
|
||||||
customDataParameter,
|
customDataParameter,
|
||||||
timeoutMilliseconds);
|
timeoutMilliseconds,
|
||||||
|
requestPathBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import { run as domainTaskRun, baseUrl as domainTaskBaseUrl } from 'domain-task/
|
|||||||
const defaultTimeoutMilliseconds = 30 * 1000;
|
const defaultTimeoutMilliseconds = 30 * 1000;
|
||||||
|
|
||||||
export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
|
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.
|
// 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.
|
// The boot code will wait for this before performing its final render.
|
||||||
let domainTaskCompletionPromiseResolve;
|
let domainTaskCompletionPromiseResolve;
|
||||||
@@ -19,6 +19,7 @@ export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
|
|||||||
location: url.parse(requestPathAndQuery),
|
location: url.parse(requestPathAndQuery),
|
||||||
origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host,
|
origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host,
|
||||||
url: requestPathAndQuery,
|
url: requestPathAndQuery,
|
||||||
|
baseUrl: (requestPathBase || '') + '/',
|
||||||
absoluteUrl: absoluteRequestUrl,
|
absoluteUrl: absoluteRequestUrl,
|
||||||
domainTasks: domainTaskCompletionPromise,
|
domainTasks: domainTaskCompletionPromise,
|
||||||
data: customDataParameter
|
data: customDataParameter
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ interface BootFuncParams {
|
|||||||
location: any; // e.g., Location object containing information '/some/path'
|
location: any; // e.g., Location object containing information '/some/path'
|
||||||
origin: string; // e.g., 'https://example.com:1234'
|
origin: string; // e.g., 'https://example.com:1234'
|
||||||
url: string; // e.g., '/some/path'
|
url: string; // e.g., '/some/path'
|
||||||
|
baseUrl: string; // e.g., '' or '/myVirtualDir'
|
||||||
absoluteUrl: string; // e.g., 'https://example.com:1234/some/path'
|
absoluteUrl: string; // e.g., 'https://example.com:1234/some/path'
|
||||||
domainTasks: Promise<any>;
|
domainTasks: Promise<any>;
|
||||||
data: any; // any custom object passed through from .NET
|
data: any; // any custom object passed through from .NET
|
||||||
|
|||||||
Reference in New Issue
Block a user