有两种常见的 csrf 错误:
- missing csrf token
- invalid csrf token
By default egg-security plugin built in Egg requires CSRF validation against all 'unsafe' request such as POST, PUT, DELETE requests.
The error will disappear in the presence of the correct csrf token in the request. For more implementation details, see [./core/security.md#csrf].
默认情况下 鸡蛋安全Egg 中内置的插件需要针对所有“不安全”请求(例如POST, PUT,DELETE请求)进行CSRF 验证。
解决办法: 1、打开你的 config / config.default.js 这个配置文件 2、加入下面的代码: //missing csrf toke 不设置的会保持,临时使用,为了安全正式使用请设置true
//CSRF是为了防止攻击,在发起请求前要在header里设置 x-csrf-token。x-csrf-token的值要后端取
config.security = {
csrf:{
enable:false
}
}



