@angular/ssr 22.0.0-next.6 → 22.0.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_validation-chunk.mjs +47 -83
- package/fesm2022/_validation-chunk.mjs.map +1 -1
- package/fesm2022/node.mjs +34 -21
- package/fesm2022/node.mjs.map +1 -1
- package/fesm2022/ssr.mjs +13 -23
- package/fesm2022/ssr.mjs.map +1 -1
- package/package.json +7 -7
- package/types/_app-engine-chunk.d.ts +22 -0
- package/types/node.d.ts +9 -1
package/fesm2022/ssr.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeTrustProxyHeaders, sanitizeRequestHeaders, validateRequest } from './_validation-chunk.mjs';
|
|
2
2
|
import { APP_BASE_HREF, PlatformLocation } from '@angular/common';
|
|
3
3
|
import { ɵConsole as _Console, ApplicationRef, REQUEST, makeEnvironmentProviders, provideEnvironmentInitializer, inject, InjectionToken, ɵENABLE_ROOT_COMPONENT_BOOTSTRAP as _ENABLE_ROOT_COMPONENT_BOOTSTRAP, Compiler, createEnvironmentInjector, EnvironmentInjector, runInInjectionContext, ɵresetCompiledComponents as _resetCompiledComponents, REQUEST_CONTEXT, RESPONSE_INIT, LOCALE_ID } from '@angular/core';
|
|
4
4
|
import { platformServer, INITIAL_CONFIG, ɵSERVER_CONTEXT as _SERVER_CONTEXT, ɵrenderInternal as _renderInternal, provideServerRendering as provideServerRendering$1 } from '@angular/platform-server';
|
|
@@ -166,12 +166,12 @@ async function renderAngular(html, bootstrap, url, platformProviders, serverCont
|
|
|
166
166
|
search,
|
|
167
167
|
hash
|
|
168
168
|
} = envInjector.get(PlatformLocation);
|
|
169
|
-
const finalUrl =
|
|
169
|
+
const finalUrl = constructSerializedUrl(router, {
|
|
170
170
|
pathname,
|
|
171
171
|
search,
|
|
172
172
|
hash
|
|
173
173
|
}, requestPrefix);
|
|
174
|
-
const urlToRenderString =
|
|
174
|
+
const urlToRenderString = constructSerializedUrl(router, urlToRender, requestPrefix);
|
|
175
175
|
if (urlToRenderString !== finalUrl) {
|
|
176
176
|
redirectTo = [pathname, search, hash].join('');
|
|
177
177
|
}
|
|
@@ -207,7 +207,7 @@ function asyncDestroyPlatform(platformRef) {
|
|
|
207
207
|
}, 0);
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function constructSerializedUrl(router, url, prefix) {
|
|
211
211
|
const {
|
|
212
212
|
pathname,
|
|
213
213
|
hash,
|
|
@@ -220,7 +220,8 @@ function constructDecodedUrl(url, prefix) {
|
|
|
220
220
|
urlParts.push(stripTrailingSlash(pathname));
|
|
221
221
|
}
|
|
222
222
|
urlParts.push(search, hash);
|
|
223
|
-
|
|
223
|
+
const urlTree = router.parseUrl(urlParts.join(''));
|
|
224
|
+
return router.serializeUrl(urlTree);
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
function promiseWithAbort(promise, signal, errorMessagePrefix) {
|
|
@@ -386,7 +387,7 @@ class RouteTree {
|
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
getPathSegments(route) {
|
|
389
|
-
return route.split('/').filter(Boolean);
|
|
390
|
+
return route.split('/').filter(Boolean).map(decodeURIComponent);
|
|
390
391
|
}
|
|
391
392
|
traverseBySegments(segments, node = this.root, currentIndex = 0) {
|
|
392
393
|
if (currentIndex >= segments.length) {
|
|
@@ -939,7 +940,6 @@ class ServerRouter {
|
|
|
939
940
|
pathname
|
|
940
941
|
} = stripIndexHtmlFromURL(url);
|
|
941
942
|
pathname = stripMatrixParams(pathname);
|
|
942
|
-
pathname = decodeURIComponent(pathname);
|
|
943
943
|
return this.routeTree.match(pathname);
|
|
944
944
|
}
|
|
945
945
|
}
|
|
@@ -1475,9 +1475,11 @@ class AngularAppEngine {
|
|
|
1475
1475
|
manifest = getAngularAppEngineManifest();
|
|
1476
1476
|
allowedHosts;
|
|
1477
1477
|
supportedLocales = Object.keys(this.manifest.supportedLocales);
|
|
1478
|
+
trustProxyHeaders;
|
|
1478
1479
|
entryPointsCache = new Map();
|
|
1479
1480
|
constructor(options) {
|
|
1480
1481
|
this.allowedHosts = this.getAllowedHosts(options);
|
|
1482
|
+
this.trustProxyHeaders = normalizeTrustProxyHeaders(options?.trustProxyHeaders);
|
|
1481
1483
|
}
|
|
1482
1484
|
getAllowedHosts(options) {
|
|
1483
1485
|
const allowedHosts = new Set([...(options?.allowedHosts ?? []), ...this.manifest.allowedHosts]);
|
|
@@ -1488,27 +1490,15 @@ class AngularAppEngine {
|
|
|
1488
1490
|
}
|
|
1489
1491
|
async handle(request, requestContext) {
|
|
1490
1492
|
const allowedHost = this.allowedHosts;
|
|
1491
|
-
const
|
|
1493
|
+
const securedRequest = sanitizeRequestHeaders(request, this.trustProxyHeaders);
|
|
1492
1494
|
try {
|
|
1493
|
-
validateRequest(
|
|
1495
|
+
validateRequest(securedRequest, allowedHost, AngularAppEngine.ɵdisableAllowedHostsCheck);
|
|
1494
1496
|
} catch (error) {
|
|
1495
|
-
return this.handleValidationError(
|
|
1497
|
+
return this.handleValidationError(securedRequest.url, error);
|
|
1496
1498
|
}
|
|
1497
|
-
const {
|
|
1498
|
-
request: securedRequest,
|
|
1499
|
-
onError: onHeaderValidationError
|
|
1500
|
-
} = disableAllowedHostsCheck ? {
|
|
1501
|
-
request,
|
|
1502
|
-
onError: null
|
|
1503
|
-
} : cloneRequestAndPatchHeaders(request, allowedHost);
|
|
1504
1499
|
const serverApp = await this.getAngularServerAppForRequest(securedRequest);
|
|
1505
1500
|
if (serverApp) {
|
|
1506
|
-
|
|
1507
|
-
if (onHeaderValidationError) {
|
|
1508
|
-
promises.push(onHeaderValidationError.then(error => this.handleValidationError(securedRequest.url, error)));
|
|
1509
|
-
}
|
|
1510
|
-
promises.push(serverApp.handle(securedRequest, requestContext));
|
|
1511
|
-
return Promise.race(promises);
|
|
1501
|
+
return serverApp.handle(securedRequest, requestContext);
|
|
1512
1502
|
}
|
|
1513
1503
|
if (this.supportedLocales.length > 1) {
|
|
1514
1504
|
return this.redirectBasedOnAcceptLanguage(securedRequest);
|