Ilja Ilja - 10 days ago 5x
Node.js Question

Is there a way to check post to 1 url or the other in express?

I am currently proxying my session creation url with express in a way like this:'/sessions', (req, res) => {
// Logic here

Logic that goes into this proxy also repeats for my
endpoint, hence I would not want to rewrite it instead I'd want above
to also check for my second url, is this possible?


From the documentation for

The path for which the middleware function is invoked; can be any of:

  • A string representing a path.
  • A path pattern.
  • A regular expression pattern to match paths.
  • An array of combinations of any of the above.

which means you can actually pass in an array of paths['/sessions', '/confirmation'] , (req, res) => {
    // Logic here