Skip to content

Use URL port for API/WebSocket defaults, ensures the automatic switch…#241

Merged
beniroquai merged 1 commit intomasterfrom
fix-autodetectport8443
Mar 17, 2026
Merged

Use URL port for API/WebSocket defaults, ensures the automatic switch…#241
beniroquai merged 1 commit intomasterfrom
fix-autodetectport8443

Conversation

@beniroquai
Copy link
Copy Markdown
Collaborator

… 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 ;)

… 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.
Copilot AI review requested due to automatic review settings March 17, 2026 07:09
@beniroquai beniroquai merged commit a5b4bf6 into master Mar 17, 2026
14 checks passed
@beniroquai beniroquai deleted the fix-autodetectport8443 branch March 17, 2026 07:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when location.port is empty.
  • Use this computed port for both websocketPort and apiPort defaults.

💡 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,
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

Successfully merging this pull request may close these issues.

2 participants