From 5f68544a9550bb32e178d6f5691de1a07b6c85be Mon Sep 17 00:00:00 2001 From: root Date: Tue, 31 Mar 2026 20:00:02 -0400 Subject: [PATCH] nginx --- api/src/index.js | 2 +- client/src/context/SocketContext.jsx | 6 ++++-- game-server/src/index.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/src/index.js b/api/src/index.js index adde11f..2a12267 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -11,7 +11,7 @@ connectDB(); app.use( cors({ - origin: "http://localhost:5173", + origin: "*", allowedHeaders: ["Content-Type", "Authorization"], credentials: true, }), diff --git a/client/src/context/SocketContext.jsx b/client/src/context/SocketContext.jsx index 47b5df8..46b5463 100644 --- a/client/src/context/SocketContext.jsx +++ b/client/src/context/SocketContext.jsx @@ -23,8 +23,10 @@ export const SocketProvider = ({ children }) => { const userInfo = JSON.parse(localStorage.getItem("user")); - const newSocket = io(url, { - auth: { token, username: userInfo?.username }, + console.log(url.replace("game-api", "socket.io")); + const newSocket = io(url.replace("/game-api", ""), { + path: "/socket.io/", +auth: { token, username: userInfo?.username }, transports: ["websocket"], reconnectionAttempts: 5, }); diff --git a/game-server/src/index.js b/game-server/src/index.js index e12dc65..0ffd09a 100644 --- a/game-server/src/index.js +++ b/game-server/src/index.js @@ -13,7 +13,7 @@ const economyService = require("./game/EconomyService.js"); app.use( cors({ - origin: "http://localhost:5173", + origin: "*", methods: ["GET", "POST"], credentials: true, }), @@ -50,7 +50,7 @@ const registerInApi = async () => { try { await axios.post(`${config.apiBaseUrl}/servers/register`, { name: config.serverName, - url: `http://localhost:${config.port}`, + url: `https://dev-test.galaxystrike.online/game-api`, secret: config.serverSecret, isModded: false, description: config.serverDescription,