Added "api/" prefix to api routes.

Client updated to reflect changes.
This commit is contained in:
Harrison Deng 2022-04-05 17:24:41 -05:00
parent b2c4178482
commit 4aced5ed2d
2 changed files with 12 additions and 9 deletions

View File

@ -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,
});
withCredentials: process.env.NODE_ENV === "development"
};
console.log(apiClientConf);
export const apiClient = axios.create(apiClientConf);

View File

@ -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}.`);