박권수

feat. cors

1 const Koa = require('koa'); 1 const Koa = require('koa');
2 +const cors = require('@koa/cors');
2 const Router = require('koa-router'); 3 const Router = require('koa-router');
3 const bodyparser = require('koa-bodyparser'); 4 const bodyparser = require('koa-bodyparser');
4 5
...@@ -29,6 +30,7 @@ Mongoose.connect(MONGO_URL, { ...@@ -29,6 +30,7 @@ Mongoose.connect(MONGO_URL, {
29 30
30 app.use(bodyparser()); 31 app.use(bodyparser());
31 router.use('/api', api.routes()); 32 router.use('/api', api.routes());
33 +app.use(cors());
32 app.use(router.routes()).use(router.allowedMethods()); 34 app.use(router.routes()).use(router.allowedMethods());
33 35
34 app.listen(SERVER_PORT, () => { 36 app.listen(SERVER_PORT, () => {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 "author": "박권수", 17 "author": "박권수",
18 "license": "ISC", 18 "license": "ISC",
19 "dependencies": { 19 "dependencies": {
20 + "@koa/cors": "^3.1.0",
20 "moment": "^2.29.1", 21 "moment": "^2.29.1",
21 "mqtt": "^4.2.6" 22 "mqtt": "^4.2.6"
22 }, 23 },
......
This diff is collapsed. Click to expand it.