Fix pixel persistence, improve mobile

This commit is contained in:
martin 2025-08-22 20:14:48 +02:00
commit e1107ccfd4
14 changed files with 172 additions and 82 deletions

View file

@ -57,7 +57,23 @@ export function useWebSocket({
};
useEffect(() => {
const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:3001';
// Dynamically determine backend URL based on current hostname
const getBackendUrl = () => {
if (typeof window === 'undefined') return 'http://localhost:3001';
const currentHost = window.location.hostname;
const backendPort = '3001';
// If we have a custom backend URL from env, use it
if (process.env.NEXT_PUBLIC_BACKEND_URL) {
return process.env.NEXT_PUBLIC_BACKEND_URL;
}
// Otherwise, use the same hostname as frontend but with backend port
return `http://${currentHost}:${backendPort}`;
};
const backendUrl = getBackendUrl();
console.log('🔌 Initializing WebSocket connection to:', backendUrl);
const newSocket = io(backendUrl, {