Routing: canActivate is not created in --prod when using concat
See original GitHub issueπ bug report
Description
When using array_of_guards.concat(guard) as canActivate parameter in a route and building app with --prod the resulting script doesnβt have canActivate variable defined. When using [β¦array_of_guards, guard] it works fine. The issue doesnβt show when not in --prod meaning that a dev environment works fine.
π¬ Minimal Reproduction
https://github.com/mlechnioppg/guards-bug
Clone repo then run: ng build --prod Use http-server to run, eg: http-server dist/guards Click links while watching console and see that guards donβt fire when clicking one link. When testing using ng serve all logs show properly when clicked.
π Your Environment
Angular Version:
Angular CLI: 7.3.6
Node: 8.12.0
OS: win32 x64
Angular: 7.2.9
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.4
@angular-devkit/build-angular 0.12.4
@angular-devkit/build-optimizer 0.12.4
@angular-devkit/build-webpack 0.12.4
@angular-devkit/core 7.2.4
@angular-devkit/schematics 7.3.6
@angular/cli 7.3.6
@ngtools/webpack 7.2.4
@schematics/angular 7.3.6
@schematics/update 0.13.6
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
Anything else relevant?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Multiple canActivate guards all run when first fails
The problem is that when I access the route and I am not logged in I hit the AuthGuard , which fails and...
Read more >CanActivate - Angular
Interface that a class can implement to be a guard deciding if a route can be activated. If all guards return true ,...
Read more >Implementing Route Protection in Angular using CanActivate
This article will go through route protection in Angular and a step-by-step guide on implementing it using the CanActivate interface.
Read more >Angular 14 Functional Router Guards: What They Are & How ...
If for example is not authenticated we should restrict access to that ... CanLoad: While we can use CanActivate to prevent an unauthorizedΒ ......
Read more >Angular 6 Tutorial 17: Routing Protection (Login App Part 3)
This tutorial shows you how to protect routes using guards in angular and implement them in a simple login application.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same issue when I want to attach the guard for all routes
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.