const Koa = require('koa');
const app = new Koa();
const json = require('koa-json');
const cors = require('@koa/cors')
const registerRouter = require('./routes')()
app.use(json());
app.use(cors({
origin: (ctx) => {
if (ctx.url === '/test') {
return "*"; // 允许来自所有域名请求
}
return "*"; // http://localhost:3006/
},
credentials: !0
}));
app.use(registerRouter)
app.listen(3004, () => {
console.log('Koa Server Started.... listen 3004 port');
})