fix: preserve baseUrl path in WebSocket URL construction#92
Merged
maximmaxim345 merged 2 commits intoSendspin:mainfrom Apr 20, 2026
Merged
fix: preserve baseUrl path in WebSocket URL construction#92maximmaxim345 merged 2 commits intoSendspin:mainfrom
maximmaxim345 merged 2 commits intoSendspin:mainfrom
Conversation
The connect() method was discarding the path component of baseUrl when building the WebSocket URL, using only url.host. This breaks reverse proxy setups where Sendspin is served behind a subpath (e.g. Home Assistant Ingress). Changes: - Pass window.location.href as base to new URL() to support relative URLs (e.g. ./sendspin-proxy/) - Include url.pathname when constructing the WebSocket URL so the proxy path is preserved Both changes are backward-compatible: absolute URLs like http://192.168.1.100:8927 still resolve to ws://192.168.1.100:8927/sendspin since their pathname is /. Fixes Sendspin#91
…path # Conflicts: # src/index.ts
maximmaxim345
approved these changes
Apr 20, 2026
Member
maximmaxim345
left a comment
There was a problem hiding this comment.
LGTM. Thanks @sanderdw !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
connect()method was discarding the path component ofbaseUrlwhen building the WebSocket URL, using onlyurl.host. This breaks reverse proxy setups where Sendspin is served behind a subpath.Fixes #91
Changes
Two small changes in
connect():window.location.hrefas the base argument tonew URL(), so relative paths like./sendspin-proxy/resolve correctly against the current pageurl.pathnamewhen constructing the WebSocket URL, so proxy paths are not strippedBefore
http://192.168.1.100:8927ws://192.168.1.100:8927/sendspin✅https://example.com/proxy/wss://example.com/sendspin❌ (path lost)./sendspin-proxy/After
http://192.168.1.100:8927ws://192.168.1.100:8927/sendspin✅https://example.com/proxy/wss://example.com/proxy/sendspin✅./sendspin-proxy/(onhttps://ha.local/app/)wss://ha.local/app/sendspin-proxy/sendspin✅Backward Compatibility
Fully backward-compatible — absolute URLs without a path still produce the same WebSocket URL as before, since
pathnameis/which gets stripped by the trailing slash removal.