M
M
Maxim Volkov2020-11-13 12:36:14
Laravel
Maxim Volkov, 2020-11-13 12:36:14

Error 419 after migrating a Laravel site to hosting. How to fix?

After transferring the application to Laravel v.8 from the local OpenServer to the server, a problem appeared - error 419. The work of all forms - including authorization and authentication.

5fae52b6998f2806478220.jpeg
An error message 419 is issued.

As I understand it, the problem is with CSRF - protection . But the problem arose only after the transfer of the site to the server, everything worked on LAN. And of course the @csrf directives are present in the forms, and the IMPUT tag with the token in the form is formed:

<input type="hidden" name="_token" value="RIhn7KmFAjyVxFwX6STjCDHtXSEPRbAqJaX88x3D">


The problem is widespread, and discussed on the network. But none of the suggested solutions worked for me.

1. Performed all kinds of cache clearing via SSH:
php artisan optimize
php artisan cache:clear
php artisan route:cache
php artisan view:clear
php artisan config:cache
php artisan config:clear

2. Executed commands and assigned folder permissions:
chmod -R 755 storage
chmod -R 755 vendor
chmod -R 644 bootstrap/caches 3. Changed the CSRF directive to {{csrf_field()}}

according to some recommendations . 4. Made changes to the config/session.php file


'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),


None of the methods listed above on the network helped to solve the problem. I keep getting 419 errors.

I ask the community for advice on how to solve this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Volkov, 2020-11-16
@voland700

Problem solved. In my case, the problem was in the server configuration. The site is hosted on a VDS server with a BrainyCP control panel. The panel was configured for the work of sites on Bitrix, including the necessary parameter for the work of Bitrix - BrainyCP mbstring.func_overload .
According to the server logs, when trying to save any data through a form on the site, a 419 error was processed.
In the server logs, there is a record of this error in the form:

[Fri Nov 13 12:35:33.249913 2020] [proxy_fcgi:error] [pid 18854:tid 140666176743168] [client 212.45.19.58:43938] AH01071: Got error 'PHP message: PHP Deprecated:  The mbstring.func_overload directive is deprecated in Unknown on line 0', referer: http://hight-control.ru/

Which indicates problems with the PHP mbstring.func_overload setting.
The problem was solved by installing a new version of PHP 7.4 on the server with default parameters, and switching the site to work on this version of PHP.

L
louise170, 2020-11-13
@louise170

Just last week I had to face the same after moving from one hosting to another. See where you have configured folding sessions, check if there is access there. For example, I had so that the sessions were added to the memcache, but the memcache itself was forgotten to be launched on the hosting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question