-
Notifications
You must be signed in to change notification settings - Fork 0
/
server2.js
34 lines (25 loc) · 819 Bytes
/
server2.js
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
26
27
28
29
30
31
32
33
34
const express = require('express');
const bodyParse = require('body-parser');
const cookieParse = require('cookie-parser');
const app = express();
app.use(bodyParse.json());
app.use(bodyParse.urlencoded({ extended: true }));
app.use(cookieParse());
const router = express.Router();
const CORS = {
'Access-Control-Allow-Origin': 'http://localhost:8080',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Method': 'POST, GET, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
};
router.post('/more/server2', function (req, res) {
res.set(CORS);
res.json(req.cookies);
});
router.options('/more/server2', function (req, res) {
res.set(CORS);
res.end();
});
app.use(router);
const port = 8088;
module.exports = app.listen(port);