想问koa
ajax
是怎么返回数据的?
之前是使用express
可以用res.writeHead
设置头, res.write
设置返回内容, 但是koa
没有了这些方法, 要怎么返回呢?
我直接this.body =
并没有效果
Fetch API cannot load http://192.168.33.1:8888/indie/song/1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8888' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
初学koa
不是很懂, es6
正在啃, 但项目来的急啊, 先求方法解决一下
The error message seems to be a cross-domain request. The response header is missing necessary fields. Set the following header
Looks like you are using fetch. Remember to set the mode of fetch to
cors
The server does not enable cross-domain resource sharing
npm install kcors --save
Then write this sentence in front of the route
app.use(require('kcors')())
==============
Koa sets the way to return headers on the server side ctx.set('header mame', 'header content')