-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERR_ABORTED 404 (Not Found) - Doesn't support static html files #56
Comments
Hack for static files:
|
@basickarl a slightly better hack so you don't need to inject an extra script tag in your HTML :) app.get('/', function(req,res) {
res.send(browserRefresh('index.html'));
});
function browserRefresh(filePath) {
var html = fs.readFileSync(filePath);
var $ = cheerio.load(html);
$('body').append(`<script src="${process.env.BROWSER_REFRESH_URL}"></script>`);
return $.html();
} |
Were you able to get CSS working? Couldn't figure that out yet |
Thank you guys @BlakeBrown and @basickarl ! The error went away when I tried you solution. But I expected my page to refresh but nothing happens. Is it like nodemon which refresh after you press combination Ctrl + S |
Yes it refreshes after you press Ctrl + S. One way to check if this is working, start by doing As long as the script exists and you have the required
then your browser should refresh when you save |
Another option: Add {"port":"8989"} Then fix the tag to that port: <script src="http://localhost:8989/browser-refresh.js"></script> |
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:
server.js:
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.The text was updated successfully, but these errors were encountered: