tjwalch/django-livereload-server

setting `LIVERELOAD_HOST` in container/VM/similar

Closed this issue · 8 comments

Hey,
just wanted to report this:
If you set the LIVERELOAD_HOST in settings.py this host is also used in the javascript to conntect to the livereload backend, this breaks functionality in case of (dev-)container/VMs/similar setups because the backend needs to f.e. start with 0.0.0.0 but the script still needs a specific host like f.e. 127.0.0.1 in case of docker containers.
this might be not needed on a "real" docker environment like a Linux OS as the base - but there are still use cases left (besides Windows and macOS).

So, solution would be "just" to have two settings I guess ... something like LIVERELOAD_HOST and maybe LIVERELOAD_BACKENDHOST or _TARGET_HOST or something else :) - naming is a bitch :)

cheers

Is the issue here that your settings need to be different between your development environment and your deployed environments?

Not really, it‘s based on runserver serving „0.0.0.0“ not only „127.0.0.1“ or „all hosts“ vs. „localhost“

imagine you‘d want to browse you dev instance from your mobile phone within your local wifi…

hope it makes some sense :)

Right, but if you were running your development instance on 192.168.1.105, then set that to your LIVERELOAD_HOST to that. Wouldn't that work?

Yes, that would work indeed. Though if the dev server now runs in a docker container f.e. or a VM if you like, there's one more NAT/routing involved which kind of leads to 0.0.0.0 for the runserver, while from your local phone you'd still enter the host, not the container/vm...

so for those use cases it might be convenient to have this setting, while default could still be how it's now ... if it's still the case, it's been a while since I've created this issue ;)

Yes, if you wanted to change the setup, you would need to then change the value of LIVERELOAD_HOST. This is another great reason why you should configure your app with the use of environment variables, and the help of sourcing .env files for different configurations.

Closing this, as it's an issue that has more to do with Django project configuration, and isn't really an issue with this package.

sure, I'm ofc using .env and recommend it - not sure if LIVERELOAD_HOST was already an option in 2020 ... if yes I might have missed it, but usually I check at least the docs and code before opening an issue. anyways, if this is an option now, then it's already implemented, nice!

@bahag-raesenerm Funny enough, this feature did not exist in 2020, and it was the first MR that I committed to this project:

#57