Yii 2.0 测试接口跨域问题

这两天用yii写一个app接口,出现了问题,如下

Bad Request (#400)
Unable to verify your data submission.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.

© My Company 2017
Powered by [Yii Framework](http://www.yiiframework.com/)

Unable to verify your data submission
无法验证您的数据提交

原因:Yii 2.0框架跨域验证机制,csrf验证
解决方法:
在控制器添加一行,禁止验证即可(测试完别忘了删掉,影响网站安全)

public $enableCsrfValidation=false;

我是用postman测试的

你可能感兴趣的:(Yii 2.0 测试接口跨域问题)