-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (23 loc) · 785 Bytes
/
server.js
File metadata and controls
24 lines (23 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import express from "express";
import cors from "cors";
import cookieParser from "cookie-parser";
import "dotenv/config";
import AuthRouter from "./Routers/AuthRoutes.js";
import connectDB from "./config/mongodb.js";
import UserRoute from "./Routers/UserRoutes.js";
const app = express();
const port = process.env.PORT || 4000;
app.use(cookieParser());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
const allowedorigin = ["https://mearn-auth-vercel-frotend.vercel.app"];
app.use(cors({ origin: allowedorigin, credentials: true }));
connectDB();
app.use("/api/auth", AuthRouter);
app.use("/api/user", UserRoute);
app.get("/", (req, res) => {
res.send("Api working");
});
app.listen(port, () => {
console.log(`Server is lsitening on Port ${port}`);
});