diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index b7ebfdf3..00ed1b42 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -8,10 +8,10 @@ const port = 8000; const authServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8002"; const userServiceUrl = process.env.USER_SERVICE_URL || "http://localhost:8001"; -const questionServiceUrl = process.env.QUESTION_SERVICE_URL || "http://localhost:8003"; +const questionServiceUrl = + process.env.QUESTION_SERVICE_URL || "http://localhost:8003"; const statsServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8004"; - app.use(cors()); app.use(express.json()); @@ -71,7 +71,9 @@ app.get("/questions", async (req, res) => { app.get("/stats", async (req, res) => { try { // Forward the stats request to the stats service - const statsResponse = await axios.get(statsServiceUrl + "/stats", req.body); + const statsResponse = await axios.get(statsServiceUrl + "/stats", { + params: req.query, + }); res.json(statsResponse.data); } catch (error) { res @@ -98,10 +100,9 @@ app.post("/saveGame", async (req, res) => { app.get("/getstats", async (req, res) => { try { // Forward the stats request to the stats service - const statsResponse = await axios.get( - userServiceUrl + "/getstats", - req.body - ); + const statsResponse = await axios.get(userServiceUrl + "/getstats", { + params: req.query, + }); res.json(statsResponse.data); } catch (error) { res diff --git a/webapp/src/pages/Clasico/Clasico.js b/webapp/src/pages/Clasico/Clasico.js index 029d8263..8b8b81be 100644 --- a/webapp/src/pages/Clasico/Clasico.js +++ b/webapp/src/pages/Clasico/Clasico.js @@ -6,6 +6,7 @@ import Footer from "../../components/Footer/Footer.js"; const JuegoPreguntas = () => { const URL = process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000" + const [isLoading, setIsLoading] = useState(true); const [indicePregunta, setIndicePregunta] = useState(0); const [puntuacion, setPuntuacion] = useState(0); @@ -121,7 +122,7 @@ const JuegoPreguntas = () => { avgTime: tiempoMedio, }; - const response = await fetch("http://localhost:8001/userSaveGame", { + const response = await fetch(URL + "/userSaveGame", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/webapp/src/pages/Stats/Stats.js b/webapp/src/pages/Stats/Stats.js index ebef5112..d1b87b5e 100644 --- a/webapp/src/pages/Stats/Stats.js +++ b/webapp/src/pages/Stats/Stats.js @@ -4,6 +4,8 @@ import Footer from "../../components/Footer/Footer.js"; import "./Stats.css"; const Stats = () => { + const gatewayUrl = process.env.GATEWAY_SERVICE_URL || "http://localhost:8000"; + const [username, setUsername] = useState(localStorage.username); const [stats, setStats] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -11,7 +13,7 @@ const Stats = () => { useEffect(() => { const delayDebounceFn = setTimeout(() => { - fetch(`http://localhost:8001/getstats?user=${username}`) + fetch(gatewayUrl + `/getstats?user=${username}`) .then((response) => response.json()) .then((data) => { setStats(data);