Home > Back-end >  CSRF token mismatch error after uploading to host
CSRF token mismatch error after uploading to host

Time:12-30

after uploading to the host I get this message when I try to change something in the database via ajax knowing that it is working well in localhost

"message": "CSRF token mismatch.",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "/hermes/bosnacweb08/bosnacweb08ab/b1283/ipg.nmedcure47094/proxima/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",

here is my ajax code

        $.ajax({
            url: '{{ url('appointment') }}/update_status_doctor/'   appointment_id,
            type: "PATCH",
            data: {
                '_token': "{{ csrf_token() }}",
                'status': status,
                'doctor': doctor,
            },

here is route

Route::patch('/appointment/update_status_doctor/{id}', [AppointmentController::class, 'update_status_doctor'])->middleware('auth');

the solution that I did and it is not working is to put ob_start(); in index.php in public

CodePudding user response:

I guess you need to include change the ajax code to the following

$.ajax({
    url: '{!! url('appointment') !!}/update_status_doctor/'   appointment_id,
    type: "POST",
    data: {
        '_token': "{{ csrf_token() }}",
        '_method': "PATCH",
        'status': status,
        'doctor': doctor,
     }
}

  • Related