k-l-lambda Claude commited on
Commit
df06d8a
·
1 Parent(s): f39824b

Fix socket connection: remove VITE_SERVER_URL for production

Browse files

- Remove VITE_SERVER_URL from .env so frontend uses window.location.origin
- Update deploy.sh to strip VITE_SERVER_URL and .env.local files
- Re-apply frontend path fix for esbuild bundle location

Co-Authored-By: Claude <noreply@anthropic.com>

deploy.sh CHANGED
@@ -135,6 +135,14 @@ else
135
  fi
136
  cd "$HF_SPACE"
137
 
 
 
 
 
 
 
 
 
138
  echo ""
139
  echo "✅ Files prepared and patched successfully!"
140
  echo ""
 
135
  fi
136
  cd "$HF_SPACE"
137
 
138
+ # Remove VITE_SERVER_URL from .env (production should use window.location.origin)
139
+ echo " Removing VITE_SERVER_URL from .env for production..."
140
+ cd "$HF_SPACE/trigo-web"
141
+ sed -i '/^VITE_SERVER_URL=/d' .env 2>/dev/null || true
142
+ # Also remove .env.local which has local dev settings
143
+ rm -f .env.local backend/.env.local 2>/dev/null || true
144
+ cd "$HF_SPACE"
145
+
146
  echo ""
147
  echo "✅ Files prepared and patched successfully!"
148
  echo ""
trigo-web/.env CHANGED
@@ -14,7 +14,6 @@
14
  # ============================================================================
15
 
16
  # Backend Server URL
17
- VITE_SERVER_URL=http://localhost:8157
18
 
19
  # Vite Dev Server Configuration
20
  VITE_HOST=0.0.0.0
 
14
  # ============================================================================
15
 
16
  # Backend Server URL
 
17
 
18
  # Vite Dev Server Configuration
19
  VITE_HOST=0.0.0.0
trigo-web/backend/.env.local DELETED
@@ -1,2 +0,0 @@
1
-
2
- PORT=8157
 
 
 
trigo-web/backend/package.json CHANGED
@@ -3,11 +3,11 @@
3
  "version": "1.0.0",
4
  "type": "module",
5
  "description": "Backend server for Trigo game",
6
- "main": "dist/server.js",
7
  "scripts": {
8
  "dev": "nodemon --watch src --exec tsx src/server.ts",
9
  "build": "tsc",
10
- "start": "node dist/server.js",
11
  "test": "echo \"Error: no test specified\" && exit 1"
12
  },
13
  "keywords": [
 
3
  "version": "1.0.0",
4
  "type": "module",
5
  "description": "Backend server for Trigo game",
6
+ "main": "dist/backend/src/server.js",
7
  "scripts": {
8
  "dev": "nodemon --watch src --exec tsx src/server.ts",
9
  "build": "tsc",
10
+ "start": "node dist/backend/src/server.js",
11
  "test": "echo \"Error: no test specified\" && exit 1"
12
  },
13
  "keywords": [
trigo-web/backend/src/sockets/gameSocket.ts CHANGED
@@ -67,7 +67,7 @@ export function setupSocketHandlers(io: Server, socket: Socket, gameManager: Gam
67
 
68
  // Get player list with colors
69
  const players: { [playerId: string]: { nickname: string; color: "black" | "white" } } = {};
70
- for (const [pid, player] of Object.entries(room.players) as [string, { nickname: string; color: "black" | "white" }][]) {
71
  players[pid] = {
72
  nickname: player.nickname,
73
  color: player.color
 
67
 
68
  // Get player list with colors
69
  const players: { [playerId: string]: { nickname: string; color: "black" | "white" } } = {};
70
+ for (const [pid, player] of Object.entries(room.players)) {
71
  players[pid] = {
72
  nickname: player.nickname,
73
  color: player.color
trigo-web/backend/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "compilerOptions": {
3
  "target": "ES2020",
4
- "module": "Node20",
5
  "lib": ["ES2020"],
6
  "outDir": "./dist",
7
  "rootDir": "../",
@@ -9,7 +9,7 @@
9
  "esModuleInterop": true,
10
  "skipLibCheck": true,
11
  "forceConsistentCasingInFileNames": true,
12
- "moduleResolution": "Node20",
13
  "resolveJsonModule": true,
14
  "declaration": true,
15
  "declarationMap": true,
@@ -18,12 +18,12 @@
18
  "allowJs": true,
19
  "noImplicitAny": false
20
  },
21
- "include": ["src/**/*", "../inc/trigo/**/*"],
22
- "exclude": ["node_modules", "dist", "../inc/trigo/parserInit.ts"],
23
  "ts-node": {
24
- "esm": true,
25
  "compilerOptions": {
26
- "module": "Node20"
27
  }
28
  }
29
  }
 
1
  {
2
  "compilerOptions": {
3
  "target": "ES2020",
4
+ "module": "commonjs",
5
  "lib": ["ES2020"],
6
  "outDir": "./dist",
7
  "rootDir": "../",
 
9
  "esModuleInterop": true,
10
  "skipLibCheck": true,
11
  "forceConsistentCasingInFileNames": true,
12
+ "moduleResolution": "node",
13
  "resolveJsonModule": true,
14
  "declaration": true,
15
  "declarationMap": true,
 
18
  "allowJs": true,
19
  "noImplicitAny": false
20
  },
21
+ "include": ["src/**/*", "../inc/**/*"],
22
+ "exclude": ["node_modules", "dist", "../inc/trigo/parserInit.ts", "../inc/tgn/tgn.jison.cjs"],
23
  "ts-node": {
24
+ "esm": false,
25
  "compilerOptions": {
26
+ "module": "commonjs"
27
  }
28
  }
29
  }