Skip to content

Commit a0330dd

Browse files
authored
Merge pull request #91 from codeit-garden/develop
cors 설정
2 parents dd05e6a + 4c76229 commit a0330dd

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

src/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,23 @@ const cookieParser = require("cookie-parser");
1010
require("./middlewares/prismaMiddleware");
1111

1212
const app = express();
13+
const origin = process.env.FRONT_DOMAIN
14+
const allowedOrigins = [
15+
"http://localhost:3000",
16+
"http://localhost:3001",
17+
origin
18+
];
1319

1420
// 미들웨어 설정
1521
app.use(morgan('dev'));
1622
app.use(cors({
23+
origin: (origin, callback) => {
24+
if (!origin || allowedOrigins.includes(origin)) {
25+
callback(null, true);
26+
} else {
27+
callback(new Error("Not allowed by CORS"));
28+
}
29+
},
1730
credentials: true, // 쿠키 전송 허용
1831
}));
1932

src/routers/missionRouters.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const asyncHandler = require('../utils/asyncHandler');
55
const { getMissions } = require('../controllers/missionController');
66
const authMiddleware = require('../middlewares/authMiddleware');
77

8-
router.get('/list', authMiddleware, asyncHandler(getMissions));
9-
10-
118
/**
129
* @swagger
1310
* /api/mission/list:
@@ -27,28 +24,32 @@ router.get('/list', authMiddleware, asyncHandler(getMissions));
2724
* items:
2825
* type: object
2926
* properties:
30-
* id:
31-
* type: integer
32-
* description: "미션 고유 ID"
27+
* title:
28+
* type: string
29+
* description: "미션 제목"
3330
* description:
3431
* type: string
3532
* description: "미션 설명"
36-
* memberId:
33+
* type:
34+
* type: string
35+
* description: "미션 유형"
36+
* targetValue:
3737
* type: integer
38-
* description: "회원 ID"
39-
* flowerId:
38+
* description: "목표 값"
39+
* currentValue:
4040
* type: integer
41-
* description: "꽃 ID"
42-
* member:
43-
* type: object
44-
* description: "회원 정보"
45-
* flower:
46-
* type: object
47-
* description: "꽃 정보"
41+
* description: "현재 진행 값"
42+
* completed:
43+
* type: boolean
44+
* description: "미션 완료 여부"
45+
* flowerName:
46+
* type: string
47+
* description: "연관된 꽃 이름"
4848
* 401:
4949
* description: "인증 실패"
5050
* 500:
5151
* description: "서버 오류"
5252
*/
53+
router.get('/list', authMiddleware, asyncHandler(getMissions));
5354

5455
module.exports = router;

0 commit comments

Comments
 (0)