Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR request raises error 500 after upgrade to vue-router 3.3.0 on beforeEach redirection #7152

Closed
dmitry opened this issue Jun 3, 2020 · 4 comments
Assignees

Comments

@dmitry
Copy link
Contributor

dmitry commented Jun 3, 2020

Running on SSR if you have router.beforeEach in boot and it redirects via next({name: 'path'}) anywhere, with new vue-router since v3.3.0 it will raise error on the server. It happens because with this release of vue-router special error are thrown: vuejs/vue-router#3047

To prevent from this issue catch should be added to the router.push(url) in the server-entry.js.

router.push(url).catch(() => {})

Probably it should be solved somehow without even catching errors at all, but for now I know the only one way how to solve that. As this file is generated automatically and it has comments

 * THIS FILE IS GENERATED AUTOMATICALLY.
 * DO NOT EDIT.

There are no real solution to that issue, except rollback to vue-router v3.2.0.

quasar/app: 1.9.5
mode: ssr
vue-router: 3.3.2

@rstoenescu rstoenescu self-assigned this Jun 3, 2020
@rstoenescu
Copy link
Member

This also means that your route is not correct.
Would you be so kind to offer a barebones reproduction repo of your issue?

@dmitry
Copy link
Contributor Author

dmitry commented Jun 3, 2020

@rstoenescu thank you for the quick response!

Here is a git repo with reproduction of this issue:
https://github.com/dmitry/quasar-route3-3-repro

If you go to the /auth (http://localhost:8080/auth) path, it will not work and results in 404 with:

UnhandledPromiseRejectionWarning: Error: Redirected from "/" to "/auth" via a navigation guard.

If you try the same on the client you will see it works, it just redirects to root URI.

@rstoenescu
Copy link
Member

This sure seems like something that's been missed on the design of the new errors in regards to SSR. Hope I'll have some bandwith to report this issue to vue-router. Their docs should get updated, including the SSR example on ssr.vuejs.org.

Meanwhile, the catch() block should be there regardless of vue-router 3.2 or 3.3. So added it for "@quasar/app" v1.9.6 -- and also temporarily downgraded vue-router to 3.2 cause on 3.3 even if we catch the error, the router.onReady hook does not matches any components and so it generates a 404 error anyway.

@dmitry
Copy link
Contributor Author

dmitry commented Jun 4, 2020

@rstoenescu thank you for the quick response as always! Your are doing a really nice software and product!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants