-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (23 loc) · 939 Bytes
/
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
import dotenv from 'dotenv';
dotenv.config();
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
import router from "./src/routers/index.js";
import { swaggerUi, specs } from "./src/swagger/swagger.js";
const app = express();
app.use(cors({
origin: ["http://localhost:5173", "http://localhost:5174" ], // 접근 권한을 부여하는 도메인들의 배열
credentials: true, // 응답 헤더에 Access-Control-Allow-Credentials 추가
optionsSuccessStatus: 200, // 응답 상태 200으로 설정
}));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use('/', router);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
const SERVER_HOST = process.env.SERVER_HOST;
const port = 3000;
app.listen(port, '0.0.0.0', () => {
console.log(`✅ Server running at http://localhost:${port} 🚀`);
});
export default app;