boilerplate-nutella icon indicating copy to clipboard operation
boilerplate-nutella copied to clipboard

Change the way of setting the PORT on server

Open allanesquina opened this issue 6 years ago • 0 comments

Based on that issue https://github.com/jaredpalmer/razzle/issues/356 I found a way to change the port by using the process.env.

const getEnv = c => process.env[c];
const PORT = getEnv('PORT');

export default Loadable.preloadAll()
  .then(() => express()
    .use((req, res) => server.handle(req, res))
    .listen(PORT, (err) => {
      if (err) {
        console.error(err);
        return;
      }
      console.log(`🤰 Running at: http://localhost:${PORT}/.`);
    })
  );

allanesquina avatar Jan 17 '19 07:01 allanesquina