Hugo 0.31.1
Windows 10 x64
--navigateToChanged
DOESN'T WORK ANYMORE
Hugo 0.30.2
Windows 10 x64
--navigateToChanged
WORKS FINE
It works fine for me on macOS. We obviously need some better automatic integration tests in this department (which is hard because it involves a browser), but I will have to wait for someone with a WIndows dev environment up and running to confirm/look at this.
/cc @anthonyfok

I've seen you made a couple of changes to livereload.go on 2017-11-12 Commit 60dfb9a6.

I've seen you made a couple of changes to livereload.go on 2017-11-12 Commit 60dfb9a.
Correct.
If I should guess, it is the CORS logic here:
https://github.com/gohugoio/hugo/blob/master/livereload/livereload.go#L55
But someone needs check this on a Windows box.
Good guess.
I've never debugged Hugo before, just setup up a basic debug environment yesterday lately.
At last with my current debug settings in Windows net.SplitHostPort throws an error because of a missing port in the address which causes the function to fail in error.

OK, so what is you running hugo server with? (flags, baseURL etc)
vscode launch.json >> ../hugo/examples/blog/config.toml
"preLaunchTask": "go-build-debug",
"name": "debug task prebuild",
"type": "go",
"request": "launch",
"mode": "exec",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/debug",
"cwd": "${workspaceRoot}/examples/blog",
"env": {},
"args": ["server", "--watch=true", "--verbose", "--port=80", "--navigateToChanged"],
===========
When I supply a different port than "--port=80" example "--port=90" the functions works flawless

... and navigateToChanged behavior is OK.
OK, then I understand, and this should not be connected to Windows. Not sure why you need to run the dev server on port 80, but it should work, so we will fix it.
I appreciate!
I tested it on a different port than 80 together with the release builds and it worked too.
Why port 80, ... because I normally use Caddy for development and always start a dedicated webserver config for each project, so port 80 is always free and 80 is the most obvious port.
Hey, so this affects not only --navigateToChanged, livereload as a feature doesn't work when hugo server runs with --port=80, because all WS connections are rejected.
Would it be enough to just add a check that Hosts are equal before comparing them without ports?
--- a/livereload/livereload.go
+++ b/livereload/livereload.go
@@ -62,6 +62,10 @@ var upgrader = &websocket.Upgrader{
return false
}
+ if u.Host == r.Host {
+ return true
+ }
+
h1, _, err := net.SplitHostPort(u.Host)
if err != nil {
return false
I've checked manually and it does fix the problem. Plus, it doesn't seem to break anything, though I can't find any tests for livereload.go.
(Oops. Sorry for broken formatting in the email, I accidentally removed the newline above code block right before submitting.)
Would it be enough to just add a check that Hosts are equal before comparing them without ports?
Yes, that should be fine.
Most helpful comment
OK, then I understand, and this should not be connected to Windows. Not sure why you need to run the dev server on port 80, but it should work, so we will fix it.