Added CORS for development environment.

This commit is contained in:
Harrison Deng 2022-04-04 20:00:12 -05:00
parent 8a3de628a6
commit c345cea888

View File

@ -6,6 +6,7 @@ import MatchController from "./controllers/matchController.js";
import SportController from "./controllers/sportController.js";
import { userSession } from "./middleware/authority.js";
import { mongooseDbName, mongoURI } from "./database/mongoose.js";
import cors from "cors";
const server = express();
const port = process.env.PORT || 5000;
@ -23,8 +24,11 @@ try {
console.error(error);
}
if (process.env.NODE_ENV === "development") {
mongoose.set("bufferCommands", false); // We want to know if there are connection issues immediately for development. Disables globally.
server.use(cors());
}
// Docs: https://www.npmjs.com/package/body-parser