Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea594f80c6 | ||
|
|
ee55c5f887 | ||
|
|
2766b4035f |
@@ -1,4 +1,4 @@
|
|||||||
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'
|
import { HashRouter as Router, Routes, Route, Navigate } from 'react-router-dom'
|
||||||
import { AuthProvider } from './contexts/AuthContext'
|
import { AuthProvider } from './contexts/AuthContext'
|
||||||
import { useAuth } from './hooks/useAuth'
|
import { useAuth } from './hooks/useAuth'
|
||||||
import LandingPage from './components/LandingPage'
|
import LandingPage from './components/LandingPage'
|
||||||
|
|||||||
@@ -1078,7 +1078,14 @@ export function useGameEngine(
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!token) return
|
if (!token) return
|
||||||
|
|
||||||
const wsUrl = `${import.meta.env.VITE_WS_URL || 'ws://localhost:8000'}/ws/game/${token}`
|
// Get WebSocket URL based on environment (same logic as api.ts)
|
||||||
|
const API_BASE = import.meta.env.VITE_API_URL || (
|
||||||
|
import.meta.env.PROD
|
||||||
|
? 'https://api-staging.echoesoftheash.com'
|
||||||
|
: 'http://localhost:8000'
|
||||||
|
)
|
||||||
|
const wsBase = API_BASE.replace(/^http/, 'ws')
|
||||||
|
const wsUrl = `${wsBase}/ws/game/${token}`
|
||||||
console.log('🔌 Connecting to WebSocket:', wsUrl)
|
console.log('🔌 Connecting to WebSocket:', wsUrl)
|
||||||
|
|
||||||
const ws = new WebSocket(wsUrl)
|
const ws = new WebSocket(wsUrl)
|
||||||
|
|||||||
@@ -6,17 +6,20 @@ import './i18n' // Initialize i18n
|
|||||||
import { registerSW } from 'virtual:pwa-register'
|
import { registerSW } from 'virtual:pwa-register'
|
||||||
import twemoji from 'twemoji'
|
import twemoji from 'twemoji'
|
||||||
|
|
||||||
// Register service worker
|
// Only register service worker when not in Electron (file:// protocol doesn't support SW)
|
||||||
registerSW({
|
const isElectron = window.location.protocol === 'file:'
|
||||||
onNeedRefresh() {
|
if (!isElectron) {
|
||||||
if (confirm('New version available! Reload to update?')) {
|
registerSW({
|
||||||
window.location.reload()
|
onNeedRefresh() {
|
||||||
}
|
if (confirm('New version available! Reload to update?')) {
|
||||||
},
|
window.location.reload()
|
||||||
onOfflineReady() {
|
}
|
||||||
console.log('App ready to work offline')
|
},
|
||||||
},
|
onOfflineReady() {
|
||||||
})
|
console.log('App ready to work offline')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize Twemoji after React renders
|
// Initialize Twemoji after React renders
|
||||||
const initTwemoji = () => {
|
const initTwemoji = () => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { VitePWA } from 'vite-plugin-pwa'
|
|||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
base: './', // Use relative paths for Electron file:// protocol
|
||||||
plugins: [
|
plugins: [
|
||||||
react(),
|
react(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
|
|||||||
Reference in New Issue
Block a user