报错提示
https://eggjs.org/zh-cn/core/security.html#安全威胁csrf的防范
跨域调试的时候报的错,比如你egg 是http://localhost:7001/ 但是你请求的post接口或者get接口是 别人的电脑,或者Postman在请求。就会报错
解决方案很简单,如果你是本地调试,可以直接在
config/config.default.js
插入一段
config.security = {
csrf: {
enable: false,
},
// 配置白名单
domainWhiteList: [ 'http://127.0.0.1:8848' ],
};
domainWhiteList: [ 'http://127.0.0.1:8848' ] 这个其实你enable 是false 你就不用管了