-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
26 lines (21 loc) · 702 Bytes
/
app.js
File metadata and controls
26 lines (21 loc) · 702 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
25
26
const express = require("express");
const app = express();
const router = require("./routes/router");
const path = require("node:path");
const cors = require("cors");
const allowList = [
"http://localhost:5173",
];
const corsOptions = {
origin: allowList,
methods: ["GET", "POST", "PUT", "DELETE"],
allowedHeaders: ["Content-Type", "Authorization"],
};
app.set("view engine", "ejs");
app.use(cors(corsOptions));
app.use(express.urlencoded({ extended: true }));
app.use("/", router);
const assetsPath = path.join(__dirname, "public");
app.use(express.static(assetsPath));
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Express app listening on port ${PORT}!`));