Use URL port for API/WebSocket defaults, ensures the automatic switch…#241
Merged
beniroquai merged 1 commit intomasterfrom Mar 17, 2026
Merged
Use URL port for API/WebSocket defaults, ensures the automatic switch…#241beniroquai merged 1 commit intomasterfrom
beniroquai merged 1 commit intomasterfrom
Conversation
… to 8443 getSmartDefaults now derives the port from window.location.port and falls back to 443 for HTTPS or 80 for HTTP when the browser omits the port. websocketPort and apiPort are set to this computed port (instead of hardcoded 80), ensuring defaults match the actual URL/protocol.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates connection settings smart defaults so the API and WebSocket ports align with the actual port the frontend is served from (including correct fallbacks when the browser omits the standard port).
Changes:
- Derive the default port from
window.location.port. - Fall back to
"443"for HTTPS and"80"for HTTP whenlocation.portis empty. - Use this computed port for both
websocketPortandapiPortdefaults.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
4
to
+11
| const getSmartDefaults = () => { | ||
| const location = window.location; | ||
| const protocol = location.protocol.replace(":", ""); // 'http' or 'https' | ||
| const hostname = location.hostname; | ||
| const isHttps = location.protocol === "https:"; | ||
| // Use the actual port from the URL; fall back to standard defaults (443/80) | ||
| // for cases where the browser omits the port (e.g. https on 443, http on 80) | ||
| const port = location.port || (isHttps ? "443" : "80"); |
| const location = window.location; | ||
| const protocol = location.protocol.replace(":", ""); // 'http' or 'https' | ||
| const hostname = location.hostname; | ||
| const isHttps = location.protocol === "https:"; |
Comment on lines
+8
to
+16
| const isHttps = location.protocol === "https:"; | ||
| // Use the actual port from the URL; fall back to standard defaults (443/80) | ||
| // for cases where the browser omits the port (e.g. https on 443, http on 80) | ||
| const port = location.port || (isHttps ? "443" : "80"); | ||
|
|
||
| return { | ||
| ip: `${protocol}://${hostname}`, | ||
| websocketPort: 80, // Both services now defaults on same port | ||
| apiPort: 80, | ||
| websocketPort: port, | ||
| apiPort: port, |
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.
… to 8443
getSmartDefaults now derives the port from window.location.port and falls back to 443 for HTTPS or 80 for HTTP when the browser omits the port. websocketPort and apiPort are set to this computed port (instead of hardcoded 80), ensuring defaults match the actual URL/protocol.
@gokugiant - hope you didn'T fix that already ;)