From 15c312729e651e25d850b43cb5b671aa3f59721e Mon Sep 17 00:00:00 2001 From: MaksSlyzar Date: Wed, 1 Apr 2026 20:43:07 +0300 Subject: [PATCH] fix .env files --- client/src/context/SocketContext.jsx | 6 ++---- game-server/src/config/config.js | 1 + game-server/src/index.js | 6 ++++-- readme.md | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/src/context/SocketContext.jsx b/client/src/context/SocketContext.jsx index 46b5463..7771900 100644 --- a/client/src/context/SocketContext.jsx +++ b/client/src/context/SocketContext.jsx @@ -22,11 +22,9 @@ export const SocketProvider = ({ children }) => { } const userInfo = JSON.parse(localStorage.getItem("user")); - - console.log(url.replace("game-api", "socket.io")); const newSocket = io(url.replace("/game-api", ""), { - path: "/socket.io/", -auth: { token, username: userInfo?.username }, + path: "/socket.io/", + auth: { token, username: userInfo?.username }, transports: ["websocket"], reconnectionAttempts: 5, }); diff --git a/game-server/src/config/config.js b/game-server/src/config/config.js index 2e6146e..d946a57 100644 --- a/game-server/src/config/config.js +++ b/game-server/src/config/config.js @@ -8,6 +8,7 @@ const config = { serverDescription: process.env.DESCRIPTION, serverRegion: process.env.REGION, dbUri: process.env.DB_URI || "local", + host: process.env.HOST, }; module.exports = config; diff --git a/game-server/src/index.js b/game-server/src/index.js index 0ffd09a..36759da 100644 --- a/game-server/src/index.js +++ b/game-server/src/index.js @@ -50,13 +50,15 @@ const registerInApi = async () => { try { await axios.post(`${config.apiBaseUrl}/servers/register`, { name: config.serverName, - url: `https://dev-test.galaxystrike.online/game-api`, + url: config.host, secret: config.serverSecret, isModded: false, description: config.serverDescription, region: config.serverRegion, }); } catch (error) { + console.log(`Error: API server not found at ${config.apiBaseUrl}`); + console.log("Please configure API_SERVER_URL= in your .env file"); process.exit(1); } }; @@ -81,7 +83,7 @@ server.listen(config.port, async () => { economyService.init(io); await registerInApi(); setInterval(sendHeartbeat, HEARTBEAT_INTERVAL); - console.log(`🚀 Server running on port ${config.port}`); + console.log(`Server running on ${config.host}. PORT: ${config.port}`); } catch (error) { console.log(error); process.exit(1); diff --git a/readme.md b/readme.md index 41fdca0..49a5cf5 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,7 @@ JWT_SECRET=secret_123 ```env PORT=5003 +HOST=http://localhost:5003 API_SERVER_URL=http://localhost:3000/api SERVER_NAME=Alpha-Centauri-3 SERVER_SECRET=game_server_pass_123