-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Hugo always forces a port when loading the liveReload javascript file if the feature is enabled
There's also the chance of manually setting the port with the flag liveReloadPort
, but this means that we need to know the port beforehand and it's not always possible.
For example, with randomly assigned ports when running Hugo in docker, since the port is assigned when starting the container, this means that we cannot set liveReloadPort
and the live reload JS will be invoked with port=1313
and thus fail.
Example:
docker run -d --rm --name hugo -p 1313 -v `pwd`/docs/hugo:/docs \
gohugoio/hugo server -w --config /docs/config.toml --source /docs --bind 0.0.0.0
When loading the page the request to load the script includes the port
http://localhost:32871/api/v1/livereload.js?mindelay=10&v=2&port=1313&path=api/v1/livereload
But the container is not listening to it, and the feature fails
docker port hugo
1313/tcp -> 0.0.0.0:32871
Solution
There's no need to enforce a port always, if it's not passed the script will use the current host and port in the URL
This solves the issue by allowing users to specify if the port should not be passed by setting liveReloadPort
to 0
.