0

I have been working through this error for days and here are the issue

My project work on localhost properly, I just uploaded it to server and this error show up! Here are some facts:

  • CSRF Token are work correctly under FORM and there is nothing wrong with it as it was in localhost
  • I tried many solutions either to change cookie name or SESSION_DOMAIN to .mydomain.com as it shown in this post

My Form is like

<form method="POST" action="{URL SUPPOSED TO BE PATCH}" accept-charset="UTF-8">
 <input name="_method" type="hidden" value="PATCH">
 <input name="_token" type="hidden" value="{Key}">
  ...
</form>

MY .env file

APP_NAME=name
APP_ENV=production
APP_KEY={key}
APP_DEBUG=ture
APP_URL={APP URL}

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE={DB NAME}
DB_USERNAME={USER NAME}
DB_PASSWORD={PASSWORD}

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379


SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_DOMAIN={.mydomain.com}


PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
ACTIVITY_LOGGER_ENABLED = true

My Session.php file

    'driver' => env('SESSION_DRIVER', 'file'),

    'lifetime' => env('SESSION_LIFETIME', 120),

    'expire_on_close' => false,

    'encrypt' => false,

    'files' => storage_path('framework/sessions'),

    'connection' => env('SESSION_CONNECTION', null),

    'table' => 'sessions',

    'store' => env('SESSION_STORE', null),

    'lottery' => [2, 100],

    'cookie' => 'test',

    'path' => '/',

    'domain' => env('SESSION_DOMAIN', null),

    'secure' => env('SESSION_SECURE_COOKIE', true),

    'http_only' => true,

    'same_site' => null,

ALSO, I have two projects with same error but not same version first project which is data above is 6.20.30 Version and second is 7.28.4

Pradeep
  • 9,667
  • 13
  • 27
  • 34
  • laravel version?? – Pradeep Aug 17 '21 at 18:35
  • I have two project on server with same error, first which his data is above is Version 6.20.30 and second is 7.28.4 – Hassan Elshazly Eida Aug 17 '21 at 18:45
  • did you run php artisan optimize:clear? The error suggests that there is no route (this is not a csrf error) – Aless55 Aug 17 '21 at 20:00
  • I believe you didn't pass the csrf token properly. You should follow the documentation and use `@method('PATCH')` and `@csrf`. Otherwise use ` ` Also, as another user pointed out, you may want to clear you app cache. When in doubt I run the following command to clear everything: `php artisan config:clear && php artisan cache:clear && composer dump-autoload && php artisan view:clear && php artisan route:clear` – LobsterBaz Aug 17 '21 at 20:05

1 Answers1

0

Solved !

the whole problem was in The Content-Length header in request

if I exceed - that what happened - size limit of body content sending to request using METHOD PATCH it will send request as POST

You can change size of your content-length through php.ini in your php folder in local or in MultiPHP INI Editor in my case (cpanel) by setting

post_max_size=500m
upload_max_filesize=500m

500m refer to 500 Mega (you can minimize or maximize it as you want)

then you should restart your apache server in local sudo service apache2 restart or restart it via WHM in server - You should have root Access -.