Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSRF token mismatch error after uploading to host

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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,
     }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading