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

Allow customising browser-facing hostname, port, and protocol #185

Open
KyeRussell opened this issue Nov 18, 2024 · 0 comments
Open

Allow customising browser-facing hostname, port, and protocol #185

KyeRussell opened this issue Nov 18, 2024 · 0 comments

Comments

@KyeRussell
Copy link

KyeRussell commented Nov 18, 2024

My Docker Compose-based development environment involves sphinx-autobuild sitting behind a reverse proxy. The reverse proxy serves sphinx-autobuild as HTTPS. This breaks a couple of assumptions made by sphinx-autobuild, particularly the largely hard-coded websocket setup HTML/JS snippet that it injects into the HTML response sent to the browser.

See:

def web_socket_script(ws_url: str) -> str:
# language=HTML
return f"""
<script>
const ws = new WebSocket("ws://{ws_url}/websocket-reload");
ws.onmessage = () => window.location.reload();
</script>
"""

ws_url is ultimately comprised of the 'host' and 'port' that sphinx-autobuild is running on.

I'd like to be able to override both of these values for all instances where sphinx-autobuild is sending them to the browser, for whatever reason, including this websocket setup. That way, the values can be customised to accommodate reverse proxy setups.

Also, the ws schema actually implies an insecure (non-HTTPS) connection. websocket-over-HTTPS connections use wss. I'd like to be able to forcibly tell sphinx-autobuild that, from the browser's perspective, it's being accessed in a HTTPS context, and for it to adjust its output appropriately (including using wss instead of ws.

I may get around to submitting a PR at some point. However, the described setup isn't at all unusual, so it felt worth logging here first, to help out anyone else running into the same thing, and maybe to even prompt someone to get in before I do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant