Bad Request (#400)

Hi Yii 2.0 community,

I’ve created my first Yii 2.0 application with the advanced template and love it. Great work.

Just uploaded my application from a localhost XAMPP on my personal computer to a hosting site.

It functions properly on my computer but on the hosting site I get:


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.



This happens when I try to login or signup.

Using:

Composer

Yii 2.0.3-dev

PHP 5.5 (both locally and on server)

Tried clearing browser cache and cookies -no change.

Found this thread and others.

Does anyone have any suggestions?

Andy

put in config


'components' =>

		'request' => [

			'enableCsrfValidation' => false],

disables "Cross-site request forgery" implementation. after you get what it is - enable

i personally didn’t check it yet as useless overhaul.

in the nutshell it should just create some random hash string to verify same in the session that is created in layout with


<?php echo Html::csrfMetaTags(); ?>

1 Like

Often, it is useful to enable logging on the Yii application and then you will see more useful errors including whether they occur in Yii or in PHP itself (in which case, they will be logged in the PHP error log).