Angular routes with a canActivate guard not working (sometimes) with prerendering #785

Closed
opened 2025-08-09 17:17:40 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @bperry77 on 5/3/2017

I have routes defined where the home route is a type of landing page. Other routes within the app are protected with an authentication guard.

In prerender mode I see the following behaviour:

  1. In-app routing, typically using router.navigate or routerLink works fine from the landing page. It also redirects correctly if my auth guard fails (returns false).
  2. Direct navigation to a protected route by entering the url in a browser's address bar gives me the following error:

Exception: Call to Node module failed with error: Error: Uncaught (in promise): TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. at Object.subscribeToResult (/home/vcap/app/ClientApp/dist/vendor.js:69061:27)

If I turn pre-rendering off, I do not see the error described in 2.

*Originally created by @bperry77 on 5/3/2017* I have routes defined where the home route is a type of landing page. Other routes within the app are protected with an authentication guard. In prerender mode I see the following behaviour: 1. In-app routing, typically using router.navigate or routerLink works fine from the landing page. It also redirects correctly if my auth guard fails (returns false). 2. Direct navigation to a protected route by entering the url in a browser's address bar gives me the following error: `Exception: Call to Node module failed with error: Error: Uncaught (in promise): TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. at Object.subscribeToResult (/home/vcap/app/ClientApp/dist/vendor.js:69061:27)` If I turn pre-rendering off, I do not see the error described in 2.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#785
No description provided.