Skip to content

Commit 82654a1

Browse files
authored
fix: Detect page protocol and use WSS for HTTPS connections for Sockets (#13)
When I deployed the UI behind https, the brower blocked connect due to insecure WebSocket endpoint Error in Chrome ``` Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://example.com/ws'. This request has been blocked; this endpoint must be available over WSS. ```
1 parent f41ef09 commit 82654a1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/static/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ let expandedSchedules = new Set(); // Track which job schedules are expanded
66

77
// API Base URL
88
const API_BASE = window.location.origin + '/api';
9-
const WS_URL = `ws://${window.location.host}/ws`;
9+
const WS_PROTOCOL = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
10+
const WS_URL = `${WS_PROTOCOL}//${window.location.host}/ws`;
1011

1112
// initialize on page load
1213
document.addEventListener('DOMContentLoaded', () => {

0 commit comments

Comments
 (0)