[Bug] Quasar 2: BeforeEach navigation guard is not firing for initial request while registered in boot files
See original GitHub issueDescribe the bug BeforeEach navigation guard is not firing while it registered within boot file for direct navigation to our SPA.
Codepen/jsFiddle/Codesandbox (required) …
To Reproduce
Put following code in .quasar/client-entry.js
and see the console output for ‘First’ and ‘Second’ messages of guards.
createQuasarApp(createApp)
.then(app =>
{
// Ok!
app.router.beforeEach((to, from, next) =>
{
console.log(`First: navigated to ${to.fullPath}`);
next();
});
return Promise.all([
import(/* webpackMode: "eager" */ 'boot/i18n'),
// import(/* webpackMode: "eager" */ 'boot/our-boot-file')
]).then(bootFiles =>
{
// Nope! This guard will not be called at startup.
app.router.beforeEach((to, from, next) =>
{
console.log(`Second: navigated to ${to.fullPath}`);
next();
});
const boot = bootFiles
.map(entry => entry.default)
.filter(entry => typeof entry === 'function')
start(app, boot)
})
})
To ensure that second guard is working:
- navigate to any wrong url within SPA.
- click on “Go Home” button.
- console will show the ‘First’ and the ‘Second’ messages.
Expected behavior BeforeEach navigation guard must catch initial navigation request in boot files.
Platform (please complete the following information): OS: Windows 10 (1809) Node: v12.16.1 Yarn: 1.22.4 Browsers: Chrome 88.0.4324.146
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Navigation guards with file boot doesn't work form me
Hello i just make register app to test login , register and navigation guards but always i can open the link i will...
Read more >Quasar framework : Navigation guards with file boot doesn't?
I resolved by creating const Router and exporting, after Route, use beforeEach with you validate. import Vue from 'vue' import VueRouter ...
Read more >Quasar - SSR and using cookies - DEV Community
2 - The Problem. You had only one instance of axios, which is shared between all requests, and each request will call the...
Read more >Build a Simple CRUD App with Spring Boot and Vue.js
This project has two major parts: Spring Boot API; Vue client. The Spring Boot app will include an H2 in-memory database and will...
Read more >Quasar V2 - Registering Global Components - YouTube
This is how you register a global component using Quasar V2 !https://quasarcast.com/ register.
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 FreeTop 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
Top GitHub Comments
Fix will be available in “@quasar/app” v3.0.0-beta.2
Would be a good idea to put that beforeEach hook code directly in /src/router/index.js