Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move PORT from package.json to config.js #81

Closed
bdefore opened this issue Jul 31, 2015 · 4 comments
Closed

move PORT from package.json to config.js #81

bdefore opened this issue Jul 31, 2015 · 4 comments

Comments

@bdefore
Copy link
Collaborator

bdefore commented Jul 31, 2015

Heroku deploys dynamically set $PORT on their dyno, so in order to fully support it we'd have to move what's currently being defined (as 8080) in package.json betterScripts start to a port property of process.env.PORT || 8080 on the config object.

I then had to modify my server.js at the bottom to:

if (config.port) {
  app.listen(config.port, (err) => {
    if (err) {
      console.error(err);
    } else {
      console.info('==> ✅  Client is listening on port', config.port);
      console.info('----------\n==> 💻  Open http://localhost:%s in a browser to view the app.', config.port);
    }
  });
} else {
  console.error('==>     ERROR: No PORT environment variable has been specified');
}

Let me know if you'd like me to formally make a PR, I won't be able to get around to it until next week though.

@erikras
Copy link
Owner

erikras commented Jul 31, 2015

I made a heroku branch to test deployment, and I ended up just running babel.server.js directly, not using npm run production.

@erikras
Copy link
Owner

erikras commented Aug 7, 2015

I kind of like having the port also be a command line parameter. In case one wanted to run two servers at one time from the same code base or something crazy like that.

@keshavmesta
Copy link

Was this change pushed to master? Heroku is still picking up the port from package.json instead of config.js for me.

@erikras
Copy link
Owner

erikras commented Jan 28, 2016

@keshavmesta No, it was not. July was like a millennium ago in JS dev time. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants