Content-Length: 286362 | pFad | https://github.com/angular/angular-cli/commit/059c10eb4df72b0d67f73783826e2bbae611ad35

E8 fix(@angular/ssr): SSR should work without `@angular/router` · angular/angular-cli@059c10e · GitHub
Skip to content

Commit 059c10e

Browse files
atscottclydin
authored andcommitted
fix(@angular/ssr): SSR should work without @angular/router
This fixes SSR to ensure serialization is not broken when router is not provided. (cherry picked from commit dfe68c7)
1 parent eee816f commit 059c10e

File tree

1 file changed

+5
-2
lines changed
  • packages/angular/ssr/src/utils

1 file changed

+5
-2
lines changed

packages/angular/ssr/src/utils/ng.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
platformServer,
2121
ɵrenderInternal as renderInternal,
2222
} from '@angular/platform-server';
23-
import { Router } from '@angular/router';
23+
import { ActivatedRoute, Router } from '@angular/router';
2424
import { Console } from '../console';
2525
import { joinUrlParts, stripIndexHtmlFromURL } from './url';
2626

@@ -98,10 +98,13 @@ export async function renderAngular(
9898

9999
// TODO(alanagius): Find a way to avoid rendering here especially for redirects as any output will be discarded.
100100
const envInjector = applicationRef.injector;
101+
const routerIsProvided = !!envInjector.get(ActivatedRoute, null);
101102
const router = envInjector.get(Router);
102103
const lastSuccessfulNavigation = router.lastSuccessfulNavigation;
103104

104-
if (lastSuccessfulNavigation?.finalUrl) {
105+
if (!routerIsProvided) {
106+
hasNavigationError = false;
107+
} else if (lastSuccessfulNavigation?.finalUrl) {
105108
hasNavigationError = false;
106109

107110
const { finalUrl, initialUrl } = lastSuccessfulNavigation;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/angular/angular-cli/commit/059c10eb4df72b0d67f73783826e2bbae611ad35

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy