How to use one port for Webpack AND api server for HEROKU?
See original GitHub issueHi,
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:
- Created 7 years ago
- Comments:6
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sascha1337
Procfile:
In Terminal in the root of your app directory:
So there you have two identical heroku apps, but one is running the command
npm run start-prod
and the othernpm run start-prod-api
. Both of these exist in thepackage.json
already, each runs either the front-end alone or the back-end.@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 nodeclient/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 theirfront-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.