From 4aced5ed2da367162e0826df48a33783256cf6a6 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Tue, 5 Apr 2022 17:24:41 -0500 Subject: [PATCH] Added "api/" prefix to api routes. Client updated to reflect changes. --- sports-matcher/client/src/utils/httpClients.js | 9 ++++++--- sports-matcher/server/server.js | 12 ++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sports-matcher/client/src/utils/httpClients.js b/sports-matcher/client/src/utils/httpClients.js index e512953..1e8231e 100644 --- a/sports-matcher/client/src/utils/httpClients.js +++ b/sports-matcher/client/src/utils/httpClients.js @@ -1,6 +1,9 @@ import axios from "axios"; -export const apiClient = axios.create({ - baseURL: process.env.REACT_APP_API_HOST, +const apiClientConf = { + baseURL: process.env.REACT_APP_API_HOST + "/api/", timeout: 5000, -}); \ No newline at end of file + withCredentials: process.env.NODE_ENV === "development" +}; +console.log(apiClientConf); +export const apiClient = axios.create(apiClientConf); \ No newline at end of file diff --git a/sports-matcher/server/server.js b/sports-matcher/server/server.js index dcb9da6..6e74fd5 100644 --- a/sports-matcher/server/server.js +++ b/sports-matcher/server/server.js @@ -27,9 +27,9 @@ try { if (process.env.NODE_ENV === "development") { + console.log("We are running in development mode."); mongoose.set("bufferCommands", false); // We want to know if there are connection issues immediately for development. Disables globally. - - server.use(cors()); + server.use(cors({ credentials: true, origin: "http://localhost:3000" })); } // Docs: https://www.npmjs.com/package/body-parser @@ -38,10 +38,10 @@ server.use(bodyParser.urlencoded({ extended: true })); server.use(userSession); -server.use("/user", UserController); -server.use("/match", MatchController); -server.use("/sport", SportController); -server.use("/rental", rentalController); +server.use("/api/user", UserController); +server.use("/api/match", MatchController); +server.use("/api/sport", SportController); +server.use("/api/rental", rentalController); server.listen(port, () => { console.log(`Server listening on port ${port}.`);