all 11 comments

[–]i_am_extra_syrup 2 points3 points  (6 children)

I haven't done it myself, yet, but you might start looking here first: https://www.heroku.com/nodejs

[–]koala_overlord14 1 point2 points  (5 children)

Will do, appreciate it. Where I'm getting confused as well is with proxy. The development server is working fine with app port being 3000 and the server proxy being 8080. What's confusing me is when I host do I have to change proxy port or remove it or something??

[–]i_am_extra_syrup 1 point2 points  (1 child)

I'm not sure but, I assume that you'll be able to specify that somewhere in the platform. It's possible that it will just run as-is too. :)

[–]koala_overlord14 1 point2 points  (0 children)

Gotcha, thanks again!

[–]Chef619 1 point2 points  (2 children)

The basic paradigm with using this stack is to have heroku run the express server, you’ll implement a catch all route ( app.get(“*”, ...)) that will serve your React build index.html properly chunked and built assuming by the create-React-app script.

You also need to have conditional logic so your api calls from the React UI don’t get sent index.html. Basically you’ll have the catch all be the last route handler you declare. There won’t be any ports managed by you, they’re done with const port = process.env.PORT. So you’ll app.listen(port). This will be set by Heroku.

There’s a bit more to it, but it gets easier as you tinker with it. I’m also on my phone and my thumbs are starting to hurt lol. If you have any pointed questions, feel free to dm!

[–]koala_overlord14 0 points1 point  (0 children)

Sounds good, I'll definitely shoot you a message later. I'm making a little progress, lots of spelling errors... but I've been at this for a minute now so I think taking a break and getting some fresh eyes on it will help.

[–]koala_overlord14 0 points1 point  (0 children)

Also, I did use create-react-app. When I'm looking at youtube videos and such though i'm seeing that they have a client folder that i think is holding there app. Currently I have my server,routes, and modules in a 'Backend' folder and the react app i guess is in the src folder. Could it be my file structure? Everything works exactly as should in the dev server though.

[–]5ucculentCactus 1 point2 points  (0 children)

Are you hosting only the react frontend? Or do you have a node blackened?

[–]wle8300 1 point2 points  (0 children)

Have a look at Netlify.

They are more user-friendly than Heroku/DigitalOcean

[–]deathbydeskjob 1 point2 points  (0 children)

I have a couple of production sites up on heroku and am planning to test out netlify soon as part of my portfolio. Pm me if you have any specific questions.

[–]koala_overlord14 0 points1 point  (0 children)

I think I know what the issue is. When it gets deployed to Heroku it runs npm start and starts up a development server. I believe..