Skip to content

Commit 835411c

Browse files
committed
Node:尝试用 koa2-cors 跨域;尝试用 koa-bodyparser 获取 Request Body
1 parent 277ac0d commit 835411c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

js/server.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
const Koa = require('koa');
2+
//const cors = require('koa2-cors');
3+
//const bodyParser = require('koa-bodyparser');
4+
25
// const Vue = require('vue');
36
const {getRequestFromURL, App} = require('./main');
47
// const { createBundleRenderer } = require('vue-server-renderer')
@@ -66,6 +69,20 @@ function update() {
6669
const PORT = 3002;
6770

6871
const app = new Koa();
72+
73+
//app.use(cors({
74+
// origin: function(ctx) {
75+
// return '*';
76+
// },
77+
// maxAge: 5,
78+
// credentials: true,
79+
// allowMethods: ['GET', 'HEAD ', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
80+
// allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
81+
// exposeHeaders: ['WWW-Authenticate', 'Server-Authorization']
82+
//}));
83+
84+
//app.use(bodyParser());
85+
6986
var done = false;
7087

7188
app.use(async ctx => {

0 commit comments

Comments
 (0)