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

Conditional redirection issue #83

Open
rdrglpzcnt opened this issue May 20, 2020 · 1 comment
Open

Conditional redirection issue #83

rdrglpzcnt opened this issue May 20, 2020 · 1 comment

Comments

@rdrglpzcnt
Copy link

rdrglpzcnt commented May 20, 2020

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
Copy link
Author

:(

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