3 Commits

4 changed files with 24 additions and 13 deletions

View File

@@ -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 { useAuth } from './hooks/useAuth'
import LandingPage from './components/LandingPage'

View File

@@ -1078,7 +1078,14 @@ export function useGameEngine(
useEffect(() => {
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)
const ws = new WebSocket(wsUrl)

View File

@@ -6,8 +6,10 @@ import './i18n' // Initialize i18n
import { registerSW } from 'virtual:pwa-register'
import twemoji from 'twemoji'
// Register service worker
registerSW({
// Only register service worker when not in Electron (file:// protocol doesn't support SW)
const isElectron = window.location.protocol === 'file:'
if (!isElectron) {
registerSW({
onNeedRefresh() {
if (confirm('New version available! Reload to update?')) {
window.location.reload()
@@ -16,7 +18,8 @@ registerSW({
onOfflineReady() {
console.log('App ready to work offline')
},
})
})
}
// Initialize Twemoji after React renders
const initTwemoji = () => {

View File

@@ -4,6 +4,7 @@ import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig({
base: './', // Use relative paths for Electron file:// protocol
plugins: [
react(),
VitePWA({