I have an app created by create-react-app. After building, it generates a html file with some JS and CSS files. The html file looks like
<!doctype html>...<script src="/static/js/main.89f33fbb.chunk.js"></script></body></html>
I try to host those static files by an Express.js server.
const app = express()
.use(bodyParser.json())
.use(express.static(path.join(__dirname, '../dist')))
app.listen(5000, '0.0.0.0');
When I try to open http://127.0.0.1:5000 or http://localhost:5000 in browser, it has no issue to load the whole page.
However, when I try to open http://0.0.0.0:5000, it first gets the html file successfully. However, in the following requests, it tries to get JS and CSS files through https
that do not exist.
I know the <script src="/static/js/main.89f33fbb.chunk.js">
will try to get the file through https
first, but if not exist, I expect it to get through http
.
I tried Chrome, Firefox, and Safari in private mode, and the results are same.
Is there any place I did wrong?