出现400错误是yii2.0的csrf防范策略导致

在components里面添加request配置如下:

'request' => [
    // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
    'cookieValidationKey' => '83r5HbITBiMfmiYPOZFdL-raVp4O1VV4',
    'enableCookieValidation' => false,
    'enableCsrfValidation' => FALSE,
],        
],

添加后再运行就没有报400错误。
但这样就关闭了yii2.0提供的csrf防御模块

或者在action里添加

$this->enableCsrfValidation = false;

相关文章:

  • 2021-08-07
  • 2021-08-07
  • 2021-11-30
  • 2021-12-13
  • 2021-09-17
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2021-11-08
  • 2021-08-07
  • 2021-08-07
  • 2021-05-05
  • 2021-11-27
相关资源
相似解决方案