Categories
express heroku javascript node.js

Deploying node app to heroku with client and server in two separate folders

I’ve done a bunch of research and I can’t quite seem to wrap my head around this.

I’ve built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081. In essence, I have this:

client
- package.json
- node_modules
- src
- build
- index.html
server
- package.json
- node_modules
- app.js
- auth.js

I’m unsure of how to resolve the folder structure so that I can deploy this to Heroku.

According to a bunch of research I’ve done and this answer (admittedly quite an old post), one suggestion is to combine the two, but how would I resolve the two package.json files that I have in each folder (client and server)? Do I merge them?

Another suggestion is to create two separate Heroku apps. I can then set my axios baseURL to app_name.herokuapp.com?

Which of the two is generally considered the ideal solution? I’m really stuck here…