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

Issues setting beforeEnter in extendRoute, for Auth0 authentication #66

Closed
SimStm opened this issue Jun 28, 2021 · 2 comments
Closed

Issues setting beforeEnter in extendRoute, for Auth0 authentication #66

SimStm opened this issue Jun 28, 2021 · 2 comments

Comments

@SimStm
Copy link

SimStm commented Jun 28, 2021

Hi.

In my project I'm implementing Auth0 authentication in Vue 3 using Vite for the first time. For now, creating the route manually, I can apply the "routeGuard" function in "beforeEnter" normally. The route is mounted correctly and the redirect works as it should.

image

The problem is when I apply the "vite-plugin-pages" auto-router, when I try to pass the "routeGuard" through the extendRoute in vite.config.ts (as described in Issue #53), my code stops working.

image

Debugging the code, looks like the routeGuard function is translated to string (instead of function), and breaks vue-router.

image
image

Am I doing something wrong? Or the way I'm calling the "routeGuard" function is wrong? Is it possible to define the "beforeEnter" for the routes in "router.ts" file or do I need to set through vite.config.ts?

Thanks!

@hannoeru
Copy link
Owner

Currently you can't use beforeEnter in extendRoute, I don't think that will works too. maybe you should modify the routes that imported from virtual:generated-pages.

@SimStm
Copy link
Author

SimStm commented Jun 29, 2021

Awesome. I was seeing the problem from a different perspective and hasn't noticed that the solution was quite simple.

image

Worked like a charm now, and together with the 'vite-plugin-vue-layouts'.

Thanks!

@SimStm SimStm closed this as completed Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants