Can anyone help me have a look at my code

heroku[router]: at=info code=H81 desc=“Blank app” method=GET path=“/”
heroku[router]: at=error code=H10 desc=“App crashed” method=GET path=“/”
Here are the 2 errors message I got when trying to deploy my first MERN project to heroku. It’s ecommerce app. It runs fine one my local machine.
Here is my package.json

{
  "main": "abc_server.js",
  "engines": {
    "node": "16.15.1"
  },
  "dependencies": {
    "bcrypt": "^5.0.1",
    "body-parser": "^1.20.0",
    "cors": "^2.8.5",
    "date-fns": "^2.29.2",
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "mongoose": "^6.5.3",
    "path": "^0.12.7",
    "serve": "^14.0.1"
  },
  "scripts": {
    "start": "node abc_server.js",
    "heroku-postbuild": "cd abc-ecommerce && npm install && npm run build"
  }
}

I didn’t use a hard port

const port=process.env.PORT
app.listen(port || 3001, ()=>{
  console.log(`server is listenning on ${port}`);
})

There seems to be an HTTP error with your API. Your GET request isn’t returning anything and your app isn’t pulling in any data.

The error also says your app is blank.

Can you share the code you wrote to make the GET request?

useEffect(() => {
    const fetchProducts = async () => {
      dispatch({ type: 'FETCH_REQUEST' });
      axios.get('/api/products').then(
        res=>{
          dispatch({ type: 'FETCH_SUCCESS', payload: res.data });
        },
        err=>{
          dispatch({ type: 'FETCH_FAIL', payload: err.message })
        }
      )
    }
    fetchProducts();
  }, []);

Thanks. This happened when I tried to deploy my first mern project to heroku. My app run fines on my local machine.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.