Skip to content

Commit

Permalink
Node:尝试用 koa2-cors 跨域;尝试用 koa-bodyparser 获取 Request Body
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed May 14, 2023
1 parent cdf1466 commit 0b8b90f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions js/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const Koa = require('koa');
//const cors = require('koa2-cors');
//const bodyParser = require('koa-bodyparser');

// const Vue = require('vue');
const {getRequestFromURL, App} = require('./main');
// const { createBundleRenderer } = require('vue-server-renderer')
Expand Down Expand Up @@ -66,6 +69,20 @@ function update() {
const PORT = 3000;

const app = new Koa();

//app.use(cors({
// origin: function(ctx) {
// return '*';
// },
// maxAge: 5,
// credentials: true,
// allowMethods: ['GET', 'HEAD ', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
// allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
// exposeHeaders: ['WWW-Authenticate', 'Server-Authorization']
//}));

//app.use(bodyParser());

var done = false;

app.use(async ctx => {
Expand Down

0 comments on commit 0b8b90f

Please sign in to comment.