score:5

I was able to fix this issue on my react app using Windows 10 by performing the following steps. First make sure you include Express in your project. From your project root:

npm install express --save

Then create a server.js file in your project's root folder and add the following to it:

const express = require('express');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 5000;

app.use(express.static(path.join(__dirname, 'build')));

app.get('*', function (req, res) {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(PORT);

Next create a Procfile (no extension) file in your project's root folder. Make sure you name it Procfile with a capital "P". Heroku looks for the exact filename and if it doesn't find it, it will not include it in the build. In Procfile add:

web: node server.js

Again, make sure it is typed exactly like this. If there are any extra spaces it will crash the app and return error H10 again. That should be all you need. Commit the changes to Heroku and heroku restart for good measure before heroku open

Hope that helps anyone else still having this problem.

score:11

There's something wrong with the new CRA start script. Use serve instead:

npm install --save serve

Change start to use serve in package.json

start: "serve -s build"

Related Query

More Query from same tag