Skip to content

ERR_ABORTED 404 (Not Found) - Doesn't support static html files #56

@basickarl

Description

@basickarl

I get the following error in the client side console:

2127.0.0.1/:25 GET http://127.0.0.1:4000/%7Bprocess.env.BROWSER_REFRESH_URL%7D net::ERR_ABORTED 404 (Not Found)

client/index.html:

<!doctype html>

<html lang="en">
    <head>
        <meta charset="utf-8">

        <title>The HTML5 Herald</title>
        <meta name="description" content="The HTML5 Herald">
        <meta name="author" content="SitePoint">

        <link rel="stylesheet" href="static/style.css">

    </head>

    <body>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>

        <canvas id="chart" width="400" height="400"></canvas>

        <script src="static/client.js"></script>
        <script src="{process.env.BROWSER_REFRESH_URL}"></script>
    </body>
</html>

server.js:

const express = require('express');

const app = express();
const port = 4000;

app.use('/static', express.static(__dirname + '/client'));

app.get('/', function (req, res) {
    res.sendfile('client/index.html');
})

app.listen(port, () => {
    console.log(`Listening on port ${port}`);

    if (process.send) {
        process.send('online');
    }
});

As you can see, I don't have a templating engine. I think you should make it clear that it only supports using with templating and not with static html files.

Perhaps you could manually allocate the port which browser refresh uses, then just hardcode it in?
So you set a port field in the process.send, which then sets the browser-refresh server up which serves the browser-refresh.js file, then as I stated before, just hardcode <script src="http://127.0.0.1:4001/browser-refresh.js"></script> in the html file. This should make it work for static html files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions