Showing
3 changed files
with
21 additions
and
1 deletions
... | @@ -6,7 +6,7 @@ const fs = require("fs"); | ... | @@ -6,7 +6,7 @@ const fs = require("fs"); |
6 | const morgan = require("koa-morgan"); | 6 | const morgan = require("koa-morgan"); |
7 | const jwtMiddleware = require("./src/lib/jwtMiddleware"); | 7 | const jwtMiddleware = require("./src/lib/jwtMiddleware"); |
8 | const api = require("./src/api"); | 8 | const api = require("./src/api"); |
9 | - | 9 | +const cors = require('@koa/cors'); // for fix CORS Error |
10 | require("dotenv").config(); | 10 | require("dotenv").config(); |
11 | 11 | ||
12 | const app = new Koa(); | 12 | const app = new Koa(); |
... | @@ -15,6 +15,7 @@ const accessLogStream = fs.createWriteStream(__dirname + "/access.log", { | ... | @@ -15,6 +15,7 @@ const accessLogStream = fs.createWriteStream(__dirname + "/access.log", { |
15 | flags: "a", | 15 | flags: "a", |
16 | }); | 16 | }); |
17 | require("dotenv").config(); | 17 | require("dotenv").config(); |
18 | +app.use(cors()); | ||
18 | app.use(bodyParser()); | 19 | app.use(bodyParser()); |
19 | app.use(jwtMiddleware); | 20 | app.use(jwtMiddleware); |
20 | app.use(morgan("combined", { stream: accessLogStream })); | 21 | app.use(morgan("combined", { stream: accessLogStream })); | ... | ... |
... | @@ -146,6 +146,14 @@ | ... | @@ -146,6 +146,14 @@ |
146 | "to-fast-properties": "^2.0.0" | 146 | "to-fast-properties": "^2.0.0" |
147 | } | 147 | } |
148 | }, | 148 | }, |
149 | + "@koa/cors": { | ||
150 | + "version": "3.1.0", | ||
151 | + "resolved": "https://registry.npmjs.org/@koa/cors/-/cors-3.1.0.tgz", | ||
152 | + "integrity": "sha512-7ulRC1da/rBa6kj6P4g2aJfnET3z8Uf3SWu60cjbtxTA5g8lxRdX/Bd2P92EagGwwAhANeNw8T8if99rJliR6Q==", | ||
153 | + "requires": { | ||
154 | + "vary": "^1.1.2" | ||
155 | + } | ||
156 | + }, | ||
149 | "@sindresorhus/is": { | 157 | "@sindresorhus/is": { |
150 | "version": "0.14.0", | 158 | "version": "0.14.0", |
151 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", | 159 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", |
... | @@ -826,6 +834,15 @@ | ... | @@ -826,6 +834,15 @@ |
826 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | 834 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", |
827 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" | 835 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" |
828 | }, | 836 | }, |
837 | + "cors": { | ||
838 | + "version": "2.8.5", | ||
839 | + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", | ||
840 | + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", | ||
841 | + "requires": { | ||
842 | + "object-assign": "^4", | ||
843 | + "vary": "^1" | ||
844 | + } | ||
845 | + }, | ||
829 | "cron-parser": { | 846 | "cron-parser": { |
830 | "version": "2.15.0", | 847 | "version": "2.15.0", |
831 | "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.15.0.tgz", | 848 | "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-2.15.0.tgz", | ... | ... |
... | @@ -4,11 +4,13 @@ | ... | @@ -4,11 +4,13 @@ |
4 | "main": "index.js", | 4 | "main": "index.js", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "dependencies": { | 6 | "dependencies": { |
7 | + "@koa/cors": "^3.1.0", | ||
7 | "axios": "^0.19.2", | 8 | "axios": "^0.19.2", |
8 | "bcrypt": "^4.0.1", | 9 | "bcrypt": "^4.0.1", |
9 | "body-parser": "^1.19.0", | 10 | "body-parser": "^1.19.0", |
10 | "cheerio": "^1.0.0-rc.3", | 11 | "cheerio": "^1.0.0-rc.3", |
11 | "cookie-parser": "^1.4.5", | 12 | "cookie-parser": "^1.4.5", |
13 | + "cors": "^2.8.5", | ||
12 | "dotenv": "^8.2.0", | 14 | "dotenv": "^8.2.0", |
13 | "eslint-config-prettier": "^6.11.0", | 15 | "eslint-config-prettier": "^6.11.0", |
14 | "fs": "^0.0.1-security", | 16 | "fs": "^0.0.1-security", | ... | ... |
-
Please register or login to post a comment