const app = Koa()app.use((req, res, next) => { // res.header("Access-Control-Allow-Origin", "*") res.header("Access-Control-Allow-Origin", "http://localhost:8080") res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Content-Length, Accept, Authorization") res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS,HEAD") res.header("X-Powered-By",' 3.2.1') res.header("Content-Type", "application/json;charset=utf-8") // 支持 cookie res.header('Access-Control-Allow-Credentials', true) // 屏蔽 OPTIONS if (req.method.toLowerCase() === 'options') { return res.send() } next()})