fix .env files

This commit is contained in:
MaksSlyzar 2026-04-01 20:43:07 +03:00
parent d826f98308
commit 15c312729e
4 changed files with 8 additions and 6 deletions

View File

@ -22,11 +22,9 @@ export const SocketProvider = ({ children }) => {
} }
const userInfo = JSON.parse(localStorage.getItem("user")); const userInfo = JSON.parse(localStorage.getItem("user"));
console.log(url.replace("game-api", "socket.io"));
const newSocket = io(url.replace("/game-api", ""), { const newSocket = io(url.replace("/game-api", ""), {
path: "/socket.io/", path: "/socket.io/",
auth: { token, username: userInfo?.username }, auth: { token, username: userInfo?.username },
transports: ["websocket"], transports: ["websocket"],
reconnectionAttempts: 5, reconnectionAttempts: 5,
}); });

View File

@ -8,6 +8,7 @@ const config = {
serverDescription: process.env.DESCRIPTION, serverDescription: process.env.DESCRIPTION,
serverRegion: process.env.REGION, serverRegion: process.env.REGION,
dbUri: process.env.DB_URI || "local", dbUri: process.env.DB_URI || "local",
host: process.env.HOST,
}; };
module.exports = config; module.exports = config;

View File

@ -50,13 +50,15 @@ const registerInApi = async () => {
try { try {
await axios.post(`${config.apiBaseUrl}/servers/register`, { await axios.post(`${config.apiBaseUrl}/servers/register`, {
name: config.serverName, name: config.serverName,
url: `https://dev-test.galaxystrike.online/game-api`, url: config.host,
secret: config.serverSecret, secret: config.serverSecret,
isModded: false, isModded: false,
description: config.serverDescription, description: config.serverDescription,
region: config.serverRegion, region: config.serverRegion,
}); });
} catch (error) { } 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); process.exit(1);
} }
}; };
@ -81,7 +83,7 @@ server.listen(config.port, async () => {
economyService.init(io); economyService.init(io);
await registerInApi(); await registerInApi();
setInterval(sendHeartbeat, HEARTBEAT_INTERVAL); setInterval(sendHeartbeat, HEARTBEAT_INTERVAL);
console.log(`🚀 Server running on port ${config.port}`); console.log(`Server running on ${config.host}. PORT: ${config.port}`);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
process.exit(1); process.exit(1);

View File

@ -28,6 +28,7 @@ JWT_SECRET=secret_123
```env ```env
PORT=5003 PORT=5003
HOST=http://localhost:5003
API_SERVER_URL=http://localhost:3000/api API_SERVER_URL=http://localhost:3000/api
SERVER_NAME=Alpha-Centauri-3 SERVER_NAME=Alpha-Centauri-3
SERVER_SECRET=game_server_pass_123 SERVER_SECRET=game_server_pass_123