esausilva / example-create-react-app-express

Example on using create-react-app with a Node Express Backend
https://esausilva.com/2017/11/14/how-to-use-create-react-app-with-a-node-express-backend-api/
MIT License
374 stars 141 forks source link

Backend not working properly post-production #5

Closed andrew-levy closed 5 years ago

andrew-levy commented 5 years ago

After deploying my app on Heroku, I get the following error: GET https://weetweet.herokuapp.com/api/hello 503 (Service Unavailable)

My locally hosted app (which works perfectly) is running on localhost:3000 and the express server is running on localhost:5000. I set up the proxy as you did

{ "proxy": "http://localhost:5000/" } and the fetch call like this fetch('/api/hello') and fetch('/api/posts') (i switched world to posts)

Should I be doing something else so that Heroku can serve the backend somewhere?

Here is my code: https://github.com/andrew-levy/Twitter-React-Express Here is the web app: https://weetweet.herokuapp.com/

p.s. Thanks for the code boilerplate and the article guiding me through the process!

esausilva commented 5 years ago

Hi Andrew, I was looking at your code and noticed you are missing the module twit.

In your server.js file line 12 you have var Twit = require('twit'), however that package is not installed. Running yarn add twit under the root directory should fix it.

andrew-levy commented 5 years ago

Hahaha of course it's something small like that. It works now, thanks for taking the time to look. First react-express project down, plenty more to come.

esausilva commented 5 years ago

Awesome! Keep it up 👍