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

  • 0
    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.

    I get error message 419.

    As I understand it, there is a problem with CSRF - protection . But the problem arose only after the site was transferred to the server, everything worked on the 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 net. But none of the proposed solutions to the problem helped me.

    1. Produced 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 permissions to folders:
    chmod -R 755 storage
    chmod -R 755 vendor
    chmod -R 644 bootstrap / caches

    3. According to some recommendations, I changed the CSRF directive to {{csrf_field ()}} .

    4. Made changes to the file config / session.php
    'domain' => env('SESSION_DOMAIN', null),
    'secure' => env('SESSION_SECURE_COOKIE', false),

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

    I ask the community for advice in solving this problem.
    Laravel Anonymous, Apr 3, 2019

  • 2 Answers
  • 0
    The problem has been resolved. In my case, the problem was with the server configuration. The site is hosted on a VDS server with a BrainyCP control panel. The panel was configured for the operation of sites on Bitrix, including the necessary parameter for the operation of Bitrix - BrainyCP mbstring.func_overload .

    According to the server logs - when trying to save any data through the form on the site, 419 errors were processed.

    The server logs record this error in the form:

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

    Which says about issues with PHP setting mbstring.func_overload.

    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.

  • 0
    Just last week I had to face the same thing after moving from one hosting to another. See where you have configured the folding of sessions, check if there is access there. For example, I had it so that the sessions were formed into a memkesh, but they forgot to start the memkesh on the hosting.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!