Skip to content
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

index.html change but doesn't have any auto refreshing must to manual refresh #850

Open
HypeNeutron opened this issue Jan 26, 2023 · 4 comments
Labels

Comments

@HypeNeutron
Copy link

Environment Versions

  1. OS Type
  2. Node version: 18.6.0
  3. 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
@mfrancis33
Copy link

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.

@jcorbin
Copy link

jcorbin commented Oct 16, 2023

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.

@zbynek
Copy link
Contributor

zbynek commented Oct 17, 2023

what are the chances

Very low. This project had no merged PRs for a year. Also this issue is a duplicate of #446 (though your proposed solution is more generic).

Copy link

This issue has been inactive for 180 days

@github-actions github-actions bot added the stale label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants