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

Express Router call another route when should return Not Found (404). #4377

Closed
lucaslacerdacl opened this issue Aug 18, 2020 · 2 comments
Closed
Labels

Comments

@lucaslacerdacl
Copy link

Hello Folks, how u doing?

Here is my code:

const router = Router();

router.use(
    `${routePrefix}/v1/associate-auth/`,
    associateAuthRoutesV1(router)
  );
  router.use(
    `${routePrefix}/v1/associate/`,
    JWTVerify,
    associateRoutesV1(router)
  );
app.use('/', router);

Here is an exemple of my routes content:

  router.post('/', async (_req, res) => {
    res.send('OK');
  });

The problem is:
When I don't set the root('/') in one of routes file, Express find the next file with the same method in root ('/').

How can I configure to return 404 when there is no route specify?

@davidmashe
Copy link

Hey @lucaslacerdacl this issue is for issues regarding express itself, not its usage. Have you tried the docs? http://expressjs.com/en/4x/api.html#router

Closing, we can re-open if you can show a problem with the library.

@lucaslacerdacl
Copy link
Author

Hello @davidmashe, thank you for the answer. However, I could not find my solution in the docs, and maybe, this could be a security issue. In my exemple I use JWTVerify in routes /associate, and when I call a /associate-auth route without JWTVerify, the Router execute an /associate route without JWTVerify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants