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 abd13d5 commit 368aa6d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions UnitAuto-Admin/js/server.js
@@ -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 = 3001;

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 368aa6d

Please sign in to comment.