dungphanxuan
dungphanxuan

Reputation: 615

CSRF token doesn't work (yii2) with https

I test app on local is ok. I deploy to server with https domain. When i submit form then show 400 Error: Bad Request (#400): Unable to verify your data submission.

And have problem with Https, how can i fix it

Upvotes: 4

Views: 904

Answers (1)

Bizley
Bizley

Reputation: 18021

Maybe you have got non-secure cookies blocked when sending over https. Try this in configuration:

return [
    // ...
    'components' => [
        // ...
        'request' => [
            'class' => 'yii\web\Request',
            'csrfCookie' => [
                'httpOnly' => true,
                'secure' => true,
            ],
        ],
    ],
];

Upvotes: 7

Related Questions