server.js
const express = require('express');
const favicon = require('express-favicon');
const app = express();
app.use(favicon(__dirname + '/build/favicon.ico'));
app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname,'build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
packagae.json
"scripts" : {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
A common mistake in a create react app
is to add a homepage
in the package.json
file that does not match your site location. Once you do a production build, the assets are prepended with the value of any path after the domain.
https://nostalgic-euclid-4f95ab.netlify.com/codehangar/react-interview/static/js/main.7ab6795d.chunk.js
From the look of the path of the broken (404) asset, your homepage value looks something like:
"homepage": "https://example.com/codehangar/react-interview",
If you are going to include a homepage value, make sure it is the same as your site URL.
In your case the value should be:
"homepage": " https://nostalgic-euclid-4f95ab.netlify.com",
Note:* Typically, leave this setting out of the file until you are live and have your domain set.
Also:
server.js
file you supplied.