Skip to content

Commit d6c23ae

Browse files
committed
Add CORS
1 parent f81d436 commit d6c23ae

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"nodemon": "^1.19.1"
2626
},
2727
"dependencies": {
28+
"cors": "^2.8.5",
2829
"dotenv": "^8.1.0",
2930
"express": "^4.17.1"
3031
}

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
import "dotenv/config";
2+
import cors from "cors";
13
import express from "express";
24

35
const app = express();
46

7+
// Add CORS headers for allowing outside applications to be able to access
8+
// resources. See library documentation for more options
9+
// (i.e., whitelisting domains): https://github.com/expressjs/cors
10+
app.use(cors());
11+
512
app.get("/", (req, res) => {
613
res.send("hello world");
714
});

0 commit comments

Comments
 (0)