0

We have some issues on our MERN-App while we want to built our Website on Heroku. In the past it worked very well but after a change of my hard disk I've downloaded the git again but now heroku can't find the path of my index file.

We think that the issue happens in our server index. Please see the attached code:

Version 1

app.get("*", (req, res) => {
    res.sendFile(path.resolve(__dirname, '/../client/build/index.html'));
  });

Were we get the following error: Error: ENOENT: no such file or directory, stat '/client/build/index.html'

and Version2

app.get("*", (req, res) => {
    res.sendFile(path.resolve(__dirname, 'client/build/index.html'));
  });

Were we get the following error: Error: ENOENT: no such file or directory, stat '/app/server/client/build/index.html'

Our file structure is: -client --build ---index.html -server -index.js

When i inspect in the browser the requested backend call the URL is like: Request URL: https://xxxx.herokuapp.com/www.XXXX.de/request/requestTERM

And our package json looks like

"build": "cd client && npm run build",
"install-client": "cd client && npm install",
"heroku-postbuild": "npm run install-client && npm run build"

We have no idea to fix this issue and will probably find some help over here.

Thank you in advance

HappyGilmore
  • 41
  • 1
  • 6

0 Answers0