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

Validator has no options to pass a path prefix and therefore is not usable with multiple routes #18

Closed
paulish opened this issue May 27, 2021 · 2 comments · Fixed by #21
Labels
bug Something isn't working

Comments

@paulish
Copy link

paulish commented May 27, 2021

When express routes are used like this:

// authorization routines
app.use('/auth', require("./routes/auth"));
// user profile routines
app.use('/user', require("./routes/user"));

The validator fails to find the correct path since it uses req.route.path which returns only the the final path.

E.g. /auth/login request will have /login as req.route.path .

The solution is either use req.baseUrl together with req.route.path or to give an options to pass the baseUrl to validation methods.

@kevinccbsg kevinccbsg added the bug Something isn't working label May 28, 2021
@SBeyeMHP
Copy link

Can confirm.

Changing

), req.route.path);
to req.baseUrl + req.route.path did solve it in this setup.

@kevinccbsg
Copy link
Member

thanks for that info!! We will upload a release today 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants