[PR #22585] [CLOSED] fix: derive WebSocket protocol from window.location to fix wss:// on HTTPS deployments #65625

Closed
opened 2026-05-06 11:30:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22585
Author: @NIK-TIGER-BILL
Created: 3/11/2026
Status: Closed

Base: mainHead: fix/terminal-ws-protocol-https


📝 Commits (1)

  • 1a1829c fix: derive WebSocket protocol from window.location to fix wss:// on HTTPS

📊 Changes

1 file changed (+10 additions, -2 deletions)

View changed files

📝 src/lib/components/chat/XTerminal.svelte (+10 -2)

📄 Description

Problem

When Open WebUI is served over HTTPS but WEBUI_API_BASE_URL contains an http:// URL (e.g. an internal Kubernetes service address), XTerminal.svelte derives the WebSocket protocol by replacing the scheme in the API base URL:

const wsBase = base.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:');

Because base starts with http://, the replacement produces ws:// instead of wss://, causing a mixed-content error and a connection failure in the terminal (fixes #22581).

Fix

Use window.location.protocol to determine the correct WebSocket protocol, which always reflects what the browser actually used to load the page:

const wsProtocol =
  typeof window !== 'undefined' && window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsBase = base.replace(/^https?:/, wsProtocol);

Applied to both the direct-connect and system (admin connect) terminal paths.

Fixes #22581


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22585 **Author:** [@NIK-TIGER-BILL](https://github.com/NIK-TIGER-BILL) **Created:** 3/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/terminal-ws-protocol-https` --- ### 📝 Commits (1) - [`1a1829c`](https://github.com/open-webui/open-webui/commit/1a1829cdb7db3ce7887ed3b33f2086577de15a35) fix: derive WebSocket protocol from window.location to fix wss:// on HTTPS ### 📊 Changes **1 file changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/XTerminal.svelte` (+10 -2) </details> ### 📄 Description ## Problem When Open WebUI is served over HTTPS but `WEBUI_API_BASE_URL` contains an `http://` URL (e.g. an internal Kubernetes service address), `XTerminal.svelte` derives the WebSocket protocol by replacing the scheme in the API base URL: ```ts const wsBase = base.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:'); ``` Because `base` starts with `http://`, the replacement produces **`ws://`** instead of **`wss://`**, causing a mixed-content error and a connection failure in the terminal (fixes #22581). ## Fix Use `window.location.protocol` to determine the correct WebSocket protocol, which always reflects what the browser actually used to load the page: ```ts const wsProtocol = typeof window !== 'undefined' && window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const wsBase = base.replace(/^https?:/, wsProtocol); ``` Applied to both the direct-connect and system (admin connect) terminal paths. Fixes #22581 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 11:30:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#65625