index.html change but doesn't have any auto refreshing must to manual refresh
Environment Versions
- OS Type
- Node version: 18.6.0
- http-server version: 14.1.1
Expected result
- auto-refreshing when any in index.html change
Actual result
- index.html change but doesn't have any auto refreshing must to manual refresh
That seems like something you would have to program yourself because it would require client-side scripting. Once a server sends a webpage, it stops communicating with the client until the client makes another request. Therefore, the server can't tell your browser that index.html has changed unless you send a request yourself.
So what are the chances of the http-server binary adding support for a custom handler? Looking at lib/http-server.js, it does take a before option that would allow wiring up a project specific handler. Then it would be up to that handler to implement a change watcher and do any payload injection to facilitate live reloading.
Basically what I'd like is something like:
$ http-server --before ./my_handler
And then we'd implement various functions in my_handler.js like:
handle(req, res)basic stateless handler that needs no options- or
createHandler(options) => ((req, res) => void)a handler constructor that take some of the server options like{ root, logFn }to name a couple
If you'd be open to such a PR, I'll give it a go.
what are the chances
Very low. This project had no merged PRs for a year. Also this issue is a duplicate of https://github.com/http-party/http-server/issues/446 (though your proposed solution is more generic).
This issue has been inactive for 180 days