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

Redirect 404 for all url not match #344

Open
holdon1996 opened this issue Jun 22, 2022 · 0 comments
Open

Redirect 404 for all url not match #344

holdon1996 opened this issue Jun 22, 2022 · 0 comments

Comments

@holdon1996
Copy link

holdon1996 commented Jun 22, 2022

How can I always redirect to 404 page if is not Logged and does not have a match of all URLs router const?
I'm trying edit file router/index.js as:

{
    path: '/error/404',
    name: 'Page404',
    component: () => import('@/views/error-page/404'),
    hidden: true,
  }
  
{ path: '*', redirect: '/error/404', hidden: true }

And in file permission.js as:

if (whiteList.indexOf(to.matched[0] ? to.matched[0].path : '') !== -1) {
      // in the free login whitelist, go directly
      next();
    } else {
      console.log(from, to, next);
      // other pages that do not have permission to access are redirected to the login page.
      // next(`/login?redirect=${to.path}`);
      next({ path: '/error/404' });
      NProgress.done();
    }

I always receive a message error in chrome console as:
Uncaught (in promise) RangeError: Maximum call stack size exceeded

If not have matched all URLs for router const, I want to redirect to the 404 page. How can I fix it?

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

1 participant