-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
app.js
47 lines (42 loc) · 1.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import express from "express";
import { config } from "dotenv";
import course from "./routes/courseRoutes.js";
import user from "./routes/userRoutes.js";
import ErrorMiddleware from "./middlewares/Error.js";
import cookieParser from "cookie-parser";
import cors from "cors";
config({
path: ".env",
});
const app = express();
app.use(
cors({
origin: "https://edumi.coderypto.tech",
credentials: true,
})
);
app.use(express.json());
app.use(cookieParser());
app.use(
express.urlencoded({
extended: true,
})
);
// app.use((req, res, next) => {
// res.setHeader("Access-Control-Allow-Credentials", true);
// res.setHeader(
// "Access-Control-Allow-Methods",
// "GET, POST, PUT,DELETE,OPTIONS"
// );
// res.setHeader(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept, Authorization"
// );
// res.setHeader("Access-Control-Allow-Origin", "http://localhost:3000");
// next();
// });
// prefix
app.use("/api/v1", course);
app.use("/api/v1", user);
app.use(ErrorMiddleware);
export default app;