Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e320bc9

Browse files
committed
fix: Remove process.env reference from browser ES module
process.env does not exist in vanilla browser ES modules (no bundler). Use window.location.protocol check only for WSS detection. Co-Authored-By: claude-flow <[email protected]>
1 parent ab2e7b4 commit e320bc9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ui/config/api.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ export function buildApiUrl(endpoint, params = {}) {
107107

108108
// Helper function to build WebSocket URLs
109109
export function buildWsUrl(endpoint, params = {}) {
110-
// Always use secure WebSocket (wss://) in production or when using HTTPS
110+
// Use secure WebSocket (wss://) when serving over HTTPS or on non-localhost
111111
// Use ws:// only for localhost development
112112
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
113-
const isProduction = window.location.protocol === 'https:' || process.env.NODE_ENV === 'production';
114-
const protocol = (isProduction || !isLocalhost)
115-
? API_CONFIG.WSS_PREFIX
113+
const isSecure = window.location.protocol === 'https:';
114+
const protocol = (isSecure || !isLocalhost)
115+
? API_CONFIG.WSS_PREFIX
116116
: API_CONFIG.WS_PREFIX;
117117

118118
// Use localhost:8000 for WebSocket connections to match FastAPI backend

0 commit comments

Comments
 (0)