参考自多拉斯基 的 《Egg02 使用Postman发送Post请求》
因为egg框架自动开启了安全威胁 CSRF 的防范,所以要么在 config.default.js 中配置关闭 csrf,要么老老实实配置 cookies。
postman
需要在postman里的test标签里进行以下配置:
let csrf_token = postman.getResponseCookie("csrftoken").value
postman.clearGlobalVariable("csrftoken");
postman.setGlobalVariable("csrftoken", csrf_token);
配置Headers
- KEY
x-csrf-token
- VALUE
{{csrftoken}}