0

Currently, I am serving an HTML file and it works fine.

(I am using koa-mount and koa-static to serve an index file under the docs directory.)

app.use(mount('/docs', serve('docs')))

How can I do a conditional router in a different environment properly?

The following approach works but looks weird

// if not production
process.env !== 'production' && app.use(mount('/docs', serve('docs')))
SPG
  • 6,109
  • 14
  • 48
  • 79

1 Answers1

0

Perhaps this looks more normal?

if (process.env !== 'production') {
  app.use(mount('/docs', serve('docs')));
}

Other than a slightly different syntax, I think your general approach is sound.

You might need process.env.NODE_ENV though, that's the normal place to put this value.

Evert
  • 93,428
  • 18
  • 118
  • 189