Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions aio/content/errors/NG0507.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@name HTML content was altered after server-side rendering
@category runtime
@shortDescription HTML content was altered after server-side rendering

@description
Angular throws this error when it detects that the content generated by server-side rendering (SSR) was altered after the rendering. The process of hydration relies on the content to be untouched after SSR, which also includes whitespaces and comment nodes. Those whitespaces and comment nodes must be retained in the HTML generated by the SSR process. Learn more in the [Hydration guide](guide/hydration#constraints).

@debugging

Typically this happens in the following cases:
* Some CDN providers have a built-in feature to remove whitespaces and comment nodes from HTML as an optimization. Please verify if there is such an option in CDN configuration and turn it off.
* If you use custom post-processing of HTML generated by SSR (as a build step), make sure that this process doesn't remove whitespaces and comment nodes.
2 changes: 1 addition & 1 deletion goldens/public-api/core/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const enum RuntimeErrorCode {
// (undocumented)
MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP = 402,
// (undocumented)
MISSING_SSR_CONTENT_INTEGRITY_MARKER = 507,
MISSING_SSR_CONTENT_INTEGRITY_MARKER = -507,
// (undocumented)
MISSING_ZONEJS = 908,
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const enum RuntimeErrorCode {
INVALID_SKIP_HYDRATION_HOST = -504,
MISSING_HYDRATION_ANNOTATIONS = -505,
HYDRATION_STABLE_TIMEDOUT = -506,
MISSING_SSR_CONTENT_INTEGRITY_MARKER = 507,
MISSING_SSR_CONTENT_INTEGRITY_MARKER = -507,

// Signal Errors
SIGNAL_WRITE_FROM_ILLEGAL_CONTEXT = 600,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hydration/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function verifySsrContentsIntegrity(): void {
typeof ngDevMode !== 'undefined' && ngDevMode &&
'Angular hydration logic detected that HTML content of this page was modified after it ' +
'was produced during server side rendering. Make sure that there are no optimizations ' +
'that remove comment nodes from HTML are enabled on your CDN. Angular hydration ' +
'that remove comment nodes from HTML enabled on your CDN. Angular hydration ' +
'relies on HTML produced by the server, including whitespaces and comment nodes.');
}
}