-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (21 loc) · 717 Bytes
/
Copy pathapp.js
File metadata and controls
25 lines (21 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const express = require('express');
const userRouter = require('./routes/buyer');
const registerStoreRouter = require('./routes/store');
const bodyParser = require('body-parser');
const app = express();
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', '*');
res.header("Access-Control-Allow-Credentials", true);
if (req.method === 'OPTIONS') {
res.header('Access-Control-Allow-Methods', '*');
return res.status(200).json({});
}
next();
});
app.use(require('cors')());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(userRouter);
app.use(registerStoreRouter);
module.exports = app;