question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use one port for Webpack AND api server for HEROKU?

See original GitHub issue

Hi,

trying to deploy my build to heroku. this repository uses two ports, one webpack and one for api. but as i know, heroku just has one PORT option which gets self assigned with env port variable.

i cannot figure out how to combine the two services. how should i handle this big problem ?

https://myapp.herokuapp.com/ws/?EIO=3&transport=polling&t=LMr9Nni -> 
app[web.1]: [0] proxy error { [Error: connect ECONNREFUSED 127.0.0.1:3030]

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
OKNoahcommented, Jan 7, 2017

@sascha1337

Procfile:

web: $WEB

In Terminal in the root of your app directory:

heroku apps:create myniceapp
heroku config:set --app myniceapp WEB="npm run start-prod"
git push heroku master
heroku apps:create myniceapp-api
heroku config:set --app myniceapp-api WEB="npm run start-prod-api"
git remote add heroku-api https://git.heroku.com/myniceapp-api.git
git push heroku-api master

So there you have two identical heroku apps, but one is running the command npm run start-prod and the other npm run start-prod-api. Both of these exist in the package.json already, each runs either the front-end alone or the back-end.

0reactions
OKNoahcommented, May 22, 2018

@cedricium Probably. You can push the same repo to two different Heroku apps and just use different commands to run them. E.g. node server/index.js and node client/index.js respectively.

But there are downsides:

  • You’ll have way more dependencies to download. Your back-end server will need to download Vue, for example, and your frontend will need to download Sequelize. Can be a waste of bandwidth and time.

  • You won’t be able to use different versions of the same package between front and back. You back-end might have a dependency on a certain version of moment, but your front-end might need a newer version.

If you want easier development, some people use Vagrant or Docker to create a virtual system that runs both their seperate server repo and their front-end repo, plus any necessary databases and so on. Then they can and run their app locally with 1 command, and begin developing more quickly, while still having 2 repos. Only downside is this can be slow on older computers or lightweight models like MacBook (2015) or MacBook Air.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying Node.js Apps on Heroku
Run the npm install command in your local app directory to install the dependencies that you declared in your package.json file. $ npm...
Read more >
Setting the port for node.js server on Heroku
Your web server will be assigned a dynamic port by Heroku but to ACCESS it, you will need to use the default port...
Read more >
Run Node.js + React + Webpack on Heroku | by Angcar
Deploy React and Express to Heroku. You've got a React app, and an API server written in Express or something else. Now -...
Read more >
How to deploy a React app with an Express server on Heroku
js it would be nodemon server.js . This will start the server on port 5000 of your computer locally. If you go visit...
Read more >
Deploying with Heroku - Apollo GraphQL Docs
Replace node index.js with whichever command you use to start your Apollo Server instance. A Procfile is not required to run Apollo Server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found