lolpee69 revised this gist . Go to revision
1 file changed, 26 insertions
nodeapp.js(file created)
@@ -0,0 +1,26 @@ | |||
1 | + | const express = require("express"); | |
2 | + | const sellAndBuyRouter = require("./routers/sellAndBuy"); | |
3 | + | const bodyParser = require("body-parser"); | |
4 | + | require("./mongoose/connect_db/mongoose"); | |
5 | + | ||
6 | + | const app = express(); | |
7 | + | ||
8 | + | app.use(express.json()); | |
9 | + | app.use(bodyParser.json()); | |
10 | + | ||
11 | + | app.use((req, res, next) => { | |
12 | + | res.header("Access-Control-Allow-Origin", "*"); | |
13 | + | res.header("Access-Control-Allow-Headers", "*"); | |
14 | + | if (req.method === "OPTIONS") { | |
15 | + | res.header("Access-Control-Allow-Methods", "GET,DELETE,PATCH"); | |
16 | + | return res.status(200).json({}); | |
17 | + | } | |
18 | + | next(); | |
19 | + | }); | |
20 | + | app.use(sellAndBuyRouter); | |
21 | + | ||
22 | + | module.exports = app; | |
23 | + | ||
24 | + | ||
25 | + | ||
26 | + |
Newer
Older