René's URL Explorer Experiment


Title: Render 404 page with CanActivate guard without aborting navigation · Issue #17004 · angular/angular · GitHub

Open Graph Title: Render 404 page with CanActivate guard without aborting navigation · Issue #17004 · angular/angular

X Title: Render 404 page with CanActivate guard without aborting navigation · Issue #17004 · angular/angular

Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [X] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/an...

Open Graph Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [X] feature request [ ] support request => Please do not submit support request...

X Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [X] feature request [ ] support request => Please do not su...

Opengraph URL: https://github.com/angular/angular/issues/17004

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Render 404 page with CanActivate guard without aborting navigation","articleBody":"**I'm submitting a ...**  (check one with \"x\")\n```\n[ ] bug report => search github for a similar issue or PR before submitting\n[X] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Background**\nWhen a user navigates to a route that requires authentication and they are not authenticated, there's no way to use a `CanActivate` guard to render a 404 component and still update the url to what the user was trying to access. \n\n**Current behavior**\nLet's say a user navigates to `/protected` and is not authenticated. Currently, in the `CanActivate` guard, in order to render my 404 component, I would use `router.navigate(['404'], { skipLocationChange: true }); return false;`. However, after rendering the 404 component, the url in the address bar is the previous url before the navigation since the navigation was aborted.\n\n**Expected behavior**\nIn `CanActivate` guard, there should be a way to render the 404 route while still updating the url in the address bar to `/protected`.\n\n**Minimal reproduction of the problem with instructions**\n```ts\n@Injectable()\nexport class LoggedInGuard implements CanActivate {\n  constructor(private router: Router, private userService: UserService) {}\n\n  canActivate() {\n    if (this.userService.isLoggedIn) return true;\n\n    this.router.navigate(['/404'], { skipLocationChange: true });\n    return false;\n  }\n}\n```\nThis code will render a 404 page, but not update the url. I would like it to render 404 and update the url in the address bar to what the user was trying to access.\n\n**What is the motivation / use case for changing the behavior?**\nGithub does this, for example, if you go to https://github.com/simonxca/webpack-guide, it will render a 404 page even though the repo exists because you're not authenticated. The motivation is to prevent users from being able to distinguish between a protected from a non-existent page for security.\n\n**Please tell us about your environment:**\nMac OSX Sierra, Node 6.10.3\n\n* **Angular version:** 4.1.X\n\n* **Browser:** all\n \n* **Language:** all","author":{"url":"https://github.com/simon-xiong-ca","@type":"Person","name":"simon-xiong-ca"},"datePublished":"2017-05-24T22:52:48Z","url":"https://github.com/angular/angular/issues/17004"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d8125658-dd67-8350-5d3c-0676e65366f8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA5E:3DD488:9B5407:C66F69:6B00F139
html-safe-noncecdf7ebbbbd37ccd8c5f3b0ee9bdc72c86078655702ed1e2bbbc125e2ba7c3fc0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTVFOjNERDQ4ODo5QjU0MDc6QzY2RjY5OjZCMDBGMTM5IiwidmlzaXRvcl9pZCI6IjEyNzc4MDk0NDAxNTM3MjcyOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2c00d8ad0a0089ab5c16850183f90e3994668499f8074cabb6199d6fd2a080c7
hovercard-subject-tagissue:231193854
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/17004/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b4257c29338fefaf45e909343a42acef98bff9970b38249e46cc909a651770af/angular/angular/issues/17004
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b4257c29338fefaf45e909343a42acef98bff9970b38249e46cc909a651770af/angular/angular/issues/17004
og:image:altI'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [X] feature request [ ] support request => Please do not submit support request...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesimon-xiong-ca
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/17004#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F17004
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F17004
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/17004
Reloadhttps://github.com/angular/angular/issues/17004
Reloadhttps://github.com/angular/angular/issues/17004
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/17004
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/17004
Render 404 page with CanActivate guard without aborting navigationhttps://github.com/angular/angular/issues/17004#top
https://github.com/atscott
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/simon-xiong-ca
simon-xiong-cahttps://github.com/simon-xiong-ca
on May 24, 2017https://github.com/angular/angular/issues/17004#issue-231193854
https://github.com/simonxca/webpack-guidehttps://github.com/simonxca/webpack-guide
Nexthttps://github.com/angular/angular/issues/17004?timeline_page=1
simon-xiong-cahttps://github.com/simon-xiong-ca
on May 24, 2017https://github.com/angular/angular/issues/17004#event-1096484056
chuckjazhttps://github.com/chuckjaz
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
on May 24, 2017https://github.com/angular/angular/issues/17004#event-1096503097
jasonadenhttps://github.com/jasonaden
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
on Dec 8, 2017https://github.com/angular/angular/issues/17004#event-1379388413
https://github.com/nickwesselman
nickwesselmanhttps://github.com/nickwesselman
on Jan 5, 2018https://github.com/angular/angular/issues/17004#issuecomment-355628966
ngbothttps://github.com/apps/ngbot
Backloghttps://github.com/angular/angular/milestone/82
on Jan 23, 2018https://github.com/angular/angular/issues/17004#event-1437582602
https://github.com/JaxonWright
JaxonWrighthttps://github.com/JaxonWright
on Feb 26, 2018https://github.com/angular/angular/issues/17004#issuecomment-368567908
https://github.com/JackMorrissey
JackMorrisseyhttps://github.com/JackMorrissey
on Aug 20, 2018https://github.com/angular/angular/issues/17004#issuecomment-414459149
location.replaceState docshttps://angular.io/api/common/Location#replacestate
https://github.com/nhducseuit
nhducseuithttps://github.com/nhducseuit
on Sep 20, 2018https://github.com/angular/angular/issues/17004#issuecomment-423053680
https://github.com/laurentgoudet
laurentgoudethttps://github.com/laurentgoudet
on Dec 21, 2018https://github.com/angular/angular/issues/17004#issuecomment-449356035
@JackMorrisseyhttps://github.com/JackMorrissey
https://github.com/RomanOleksiuk
RomanOleksiukhttps://github.com/RomanOleksiuk
on Feb 5, 2019https://github.com/angular/angular/issues/17004#issuecomment-460681561
https://github.com/vahidvdn
vahidvdnhttps://github.com/vahidvdn
on Jul 13, 2019https://github.com/angular/angular/issues/17004#issuecomment-511152411
https://github.com/FirstVertex
FirstVertexhttps://github.com/FirstVertex
on Aug 7, 2019https://github.com/angular/angular/issues/17004#issuecomment-519241512
https://github.com/laurentgoudet
laurentgoudethttps://github.com/laurentgoudet
on Oct 15, 2019https://github.com/angular/angular/issues/17004#issuecomment-542080568
@JackMorrisseyhttps://github.com/JackMorrissey
https://github.com/borjapazr
borjapazrhttps://github.com/borjapazr
on Nov 4, 2019https://github.com/angular/angular/issues/17004#issuecomment-549358199
#16981https://github.com/angular/angular/issues/16981
@ccondruphttps://github.com/ccondrup
#16981 (comment)https://github.com/angular/angular/issues/16981#issuecomment-549330207
atscotthttps://github.com/atscott
on Feb 28, 2024https://github.com/angular/angular/issues/17004#event-11958156062
feat(router): Add ability to return `UrlTree` with `NavigationBehavio…https://github.com/atscott/angular/commit/850c3b8be623546547f2545186539745530e1eca
https://docs.github.com/articles/closing-issues-via-commit-messages
850c3b8https://github.com/atscott/angular/commit/850c3b8be623546547f2545186539745530e1eca
atscotthttps://github.com/atscott
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
8735af0https://github.com/angular/angular/commit/8735af08b976b30cf236a83f9e8b64b5ff62e9f3
on Mar 12, 2024https://github.com/angular/angular/issues/17004#event-12091896658
atscotthttps://github.com/atscott
on Mar 12, 2024https://github.com/angular/angular/issues/17004#event-12092006787
feat(router): Add ability to return `UrlTree` with `NavigationBehavio…https://github.com/atscott/angular/commit/8735af08b976b30cf236a83f9e8b64b5ff62e9f3
https://docs.github.com/articles/closing-issues-via-commit-messages
8735af0https://github.com/atscott/angular/commit/8735af08b976b30cf236a83f9e8b64b5ff62e9f3
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Apr 12, 2024https://github.com/angular/angular/issues/17004#issuecomment-2050745234
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Apr 12, 2024https://github.com/angular/angular/issues/17004#event-12442903156
alxhubhttps://github.com/alxhub
on May 2, 2024https://github.com/angular/angular/issues/17004#event-12686095925
angularhttps://github.com/angular
on May 2, 2024https://github.com/angular/angular/issues/17004#event-12686097605
atscotthttps://github.com/atscott
on May 30, 2024https://github.com/angular/angular/issues/17004#event-12991641509
feat(router): Set a different browser URL from the one for route matc…https://github.com/atscott/angular/commit/bb915acb02ac9314e6ac4087bcf856aedb0b9094
https://docs.github.com/articles/closing-issues-via-commit-messages
bb915achttps://github.com/atscott/angular/commit/bb915acb02ac9314e6ac4087bcf856aedb0b9094
AndrewKushnirhttps://github.com/AndrewKushnir
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
1d3a752https://github.com/angular/angular/commit/1d3a7529b4fa3617a5d6a97e742cb13818253a14
on Jun 13, 2024https://github.com/angular/angular/issues/17004#event-13152754394
angular-robothttps://github.com/angular-robot
on Jun 13, 2024https://github.com/angular/angular/issues/17004#event-13152791486
feat(router): Set a different browser URL from the one for route matc…https://github.com/angular-robot/angular/commit/1d3a7529b4fa3617a5d6a97e742cb13818253a14
https://docs.github.com/articles/closing-issues-via-commit-messages
1d3a752https://github.com/angular-robot/angular/commit/1d3a7529b4fa3617a5d6a97e742cb13818253a14
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jul 14, 2024https://github.com/angular/angular/issues/17004#issuecomment-2227144793
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jul 14, 2024https://github.com/angular/angular/issues/17004#event-13496685325
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/17004
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/17004
atscotthttps://github.com/atscott
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.