Fix: Use dynamic URLs for all frontend connections
- CSP: Allow WebSocket/HTTP connections to any domain (for production) - Nakama: Detect host/SSL from browser location instead of hardcoded localhost - WebSocket: Dynamic protocol/host detection for stream and watch sync - HLS/LLHLS/WebRTC: Dynamic URLs in live page and stream components - RTMP/SRT: Show actual domain in my-realms settings page - Forums: Use numeric forum ID for banner/title-color API calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e26fd346f3
commit
118629549e
9 changed files with 121 additions and 28 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { browser } from '$app/environment';
|
||||
|
||||
let ws = null;
|
||||
let reconnectTimeout = null;
|
||||
let reconnectAttempts = 0;
|
||||
|
|
@ -5,7 +7,17 @@ const MAX_RECONNECT_ATTEMPTS = 10;
|
|||
const BASE_RECONNECT_DELAY = 1000; // 1 second
|
||||
const MAX_RECONNECT_DELAY = 30000; // 30 seconds
|
||||
|
||||
const WS_URL = import.meta.env.VITE_WS_URL || 'ws://localhost/ws';
|
||||
// Dynamically detect WebSocket URL from browser location
|
||||
// This ensures production uses wss:// and the correct host
|
||||
function getWebSocketURL() {
|
||||
if (!browser) {
|
||||
return import.meta.env.VITE_WS_URL || 'ws://localhost/ws';
|
||||
}
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
return `${protocol}//${window.location.host}/ws`;
|
||||
}
|
||||
|
||||
const WS_URL = getWebSocketURL();
|
||||
|
||||
/**
|
||||
* Calculate exponential backoff delay with jitter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue