Repository navigation
fix(platform-server): prevent recursive SSR HttpClient requests - #72226
Closed
alan-agius4 wants to merge 1 commit into
Closed
alan-agius4 wants to merge 1 commit into
alan-agius4 wants to merge 1 commit into
Conversation
Mark outgoing `HttpClient` requests sent during server-side rendering that target the host of the page being rendered with an `x-angular-ssr-request: 1` header, and reject incoming `REQUEST` instances carrying this header in `renderApplication` and `renderModule` with `NG05707` before bootstrapping. Also export `ɵSSR_REQUEST_HEADER` and `ɵisSsrRequest` privately so `@angular/ssr` can reuse the same header contract and reject recursive SSR requests before rendering. Related to angular/angular-cli#34789
4 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: Related to angular/angular-cli#34789
During SSR, outgoing
HttpClientrequests (e.g. relative URLs resolved againstPlatformLocationwith port included) can land back on the SSR server and match a wildcard**route, triggering unbounded recursive renders until the Node.js process runs out of memory.What is the new behavior?
SERVER_HTTP_PROVIDERS(packages/platform-server/src/http.ts), mark outgoingHttpClienthttp:/https:requests targeting the host + port ofPlatformLocation(matching default ports80/443across schemes for TLS-terminating proxies, normalizing trailing FQDN dots & IPv6, and failing closed on non-HTTP/unparseable URLs) withx-angular-ssr-request: 1. Because this lives inSERVER_HTTP_PROVIDERS, it covers bothprovideServerRendering()andServerModule.ɵSSR_REQUEST_HEADERandɵisSsrRequestprivately so@angular/ssrcan reuse the same header contract and reject recursive SSR requests before rendering.renderApplicationandrenderModule, reject incomingREQUESTinstances carryingx-angular-ssr-requestwithRuntimeErrorCode.RECURSIVE_SSR_REQUEST(NG05707) before bootstrapping.Does this PR introduce a breaking change?
Other information
angular/angular-cli(@angular/ssr) will consumeɵisSsrRequest/ɵSSR_REQUEST_HEADERto return a non-cached response before route extraction / rendering.