Conditional redirection issue
rdrglpzcnt opened this issue · comments
rdrglpzcnt commented
Hello!
Need to catch THOUSANDS of old users url's matching: ^/([-_.a-zA-Z0-9]+)$
and redirect them to: /user/$1
This is my rule, where app_pages are the app main paths:
let app_pages = [
...
'admin',
'auth',
'tests',
'widgets',
'dev-login',
'user',
...
];
...
...
...
{
from: '^/([-_.a-zA-Z0-9]+)$',
to: (from, req) => {
let param = req.url.match(from)[1];
if (app_pages.includes(param)) {
//PROBLEM HERE: infinite loop
return '/$1'
}
//this route has an asyncData function that checks $1 to show profile or to return 404
return '/user/$1'
},
statusCode: 301
},
...
How can i do something like return next() or not redirecting if it matches an app_pages path?
rdrglpzcnt commented
:(