src/controller/base.js 中的 __before 中添加以下代码,即可允许全局跨域:

1
2
3
4
this.header('Access-Control-Allow-Origin', this.header('origin') || '*')
this.header('Access-Control-Allow-Headers', 'x-requested-with')
this.header('Access-Control-Request-Method', 'GET,POST,PUT,DELETE')
this.header('Access-Control-Allow-Credentials', 'true')