Fix pixel persistence, improve mobile
This commit is contained in:
parent
1f1f20ffd6
commit
e1107ccfd4
14 changed files with 172 additions and 82 deletions
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue