fix: Proxy console WebSocket through main app for HTTPS compatibility

Browser blocks mixed content (HTTPS page -> HTTP WebSocket on port 5001).
Solution: Route WebSocket through main Flask app which goes through
existing HTTPS reverse proxy.

- Add Flask-SocketIO to main mc-webui app
- WebSocket handler proxies commands to bridge via HTTP
- Remove port 5001 external exposure (no longer needed)
- Remove duplicate title from console header

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-01-09 13:18:56 +01:00
parent a5f7fd59e6
commit c376ecff30
6 changed files with 109 additions and 34 deletions
+5 -7
View File
@@ -20,20 +20,18 @@ document.addEventListener('DOMContentLoaded', function() {
});
/**
* Connect to WebSocket server on meshcore-bridge
* Connect to WebSocket server (proxied through main Flask app)
*/
function connectWebSocket() {
updateStatus('connecting');
// Get WebSocket URL - bridge runs on port 5001
// Use same hostname as current page but different port
const bridgeUrl = window.MC_CONFIG?.bridgeWsUrl ||
`${window.location.protocol}//${window.location.hostname}:5001`;
// Connect to same origin - WebSocket is proxied through main Flask app
const wsUrl = window.location.origin;
console.log('Connecting to WebSocket:', bridgeUrl);
console.log('Connecting to WebSocket:', wsUrl);
try {
socket = io(bridgeUrl + '/console', {
socket = io(wsUrl + '/console', {
transports: ['websocket', 'polling'],
reconnection: true,
reconnectionAttempts: Infinity,