After having deployed my app with success I clicked on "Open app" and I see this error:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Link with error https://fcrg.herokuapp.com/
But it does work correctly in localhost with yarn dev cli
package.json for backend app :
{
"name": "site-web-france",
"version": "1.0.0",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build",
"client": "cd client && yarn start",
"server": "nodemon server.js",
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"",
"dev:server": "cd client && yarn build && cd .. && yarn start",
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
},
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3",
"mongodb": "^3.1.1",
"mongoose": "^5.2.6",
"react-scripts": "^1.1.4"
},
"devDependencies": {
"concurrently": "^3.5.0"
}
}
I think this problem is because of "yarn", what do you think ?
tutorial followed : https://medium.freecodecamp.org/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0
Make sure that the application port is NOT hard-coded like:
app.listen(3000, ...)
It can cause problems with Heroku. Instead try using the environment variable PORT
:
app.listen(process.env.PORT || 3000, ...)
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With