question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Quasar 2: BeforeEach navigation guard is not firing for initial request while registered in boot files

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
rstoenescucommented, Feb 4, 2021

Fix will be available in “@quasar/app” v3.0.0-beta.2

2reactions
rstoenescucommented, Feb 4, 2021

Would be a good idea to put that beforeEach hook code directly in /src/router/index.js

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found