eggJS设置csrf
在config/config.default.js中设置
//config/config.default.js
module.exports = (appInfo) => {
//······
config.security = {
csrf: {
enable: false,
ignoreJSON: true,
// 判断是否需要 ignore 的方法,请求上下文 context 作为第一个参数
ignore: (ctx) => {
// if (ctx.request.url == '/admin/goods/uploadImg') {
// return true
// }
return true
},
},
}
//······
}