ptSend/index.js

24 lines
737 B
JavaScript

const Koa = require('koa');
const app = new Koa();
const static = require('koa-static')
app.use(static("./view/dist"))
const { koaBody } = require('koa-body');
const KoaSSEStream = require('koa-sse-stream');
app.use(koaBody());
app.use(async (ctx, next) => {
ctx.set('Access-Control-Allow-Origin', '*');
ctx.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With');
ctx.set('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
if (ctx.method == 'OPTIONS') {
ctx.body = 200;
} else {
await next();
}
});
const index = require("./router/index.js")
app.use(index.routes()).use(index.allowedMethods())
app.listen(3050, "0.0.0.0");