Search code examples
node.jsexpressstormpathexpress-stormpath

Bypass stormpath when in development


I am trying Stormpath via express-stormpath. I have very poor network connection so every time when the node app restarts, the page takes long time to response. It seems that the express-stormpath is doing something at background. The problem happens no matter which page I am accessing. It just takes few seconds to response even there is no stormpath validation on the route.

Can anyone tell me how to bypass all routines of Stormpath when in development mode.


Solution

  • You could simply not include the Stormpath middleware in development.

    For example:

    if (process.env.NODE_ENV === 'production') {
      app.use(stormpath.init(app, ...));
    }
    

    This will only load the Stormpath middleware if your application has an environment variable named NODE_ENV set to production.