Search code examples
node.jsexpresseveryauth

Multiple login paths for everyauth


I have a node.js + express project that's using everyauth. I'm in the process of reworking the routes and I would like to have multiple routes for the login and logout paths so two api versions can coexist at the same time.

Calling postLoginPath multiple times just makes the last call "win".

I need the login code to respond to both "/login" and "/v1/login". I was trying to register the alternate route and do some sort of server-side forward but can't find the '/login' path (which is supplied to postLoginPath) in the registered routes in 'app.routes'.


Solution

  • Ended up using this: https://npmjs.org/package/connect-modrewrite

    Here's some sample code for my example:

    app.use(modRewrite([
        '/v1/login /login',
        '/v1/logout /logout'
      ]))