Skip to content

Commit 8ce5ed8

Browse files
committed
add CORS configuration
1 parent 8df3c91 commit 8ce5ed8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"license": "ISC",
1919
"dependencies": {
2020
"body-parser": "^1.19.0",
21+
"cors": "^2.8.5",
2122
"express": "^4.17.1",
2223
"mysql2": "^2.0.2",
2324
"sequelize": "^5.21.2"

server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
const express = require("express");
22
const bodyParser = require("body-parser");
3+
const cors = require("cors");
34

45
const app = express();
56

7+
var corsOptions = {
8+
origin: "http://localhost:8081"
9+
};
10+
11+
app.use(cors(corsOptions));
12+
613
// parse requests of content-type - application/json
714
app.use(bodyParser.json());
815

0 commit comments

Comments
 (0)