2 months ago

Blocking a multi-origin request (Cross-Origin Request)

Posted 2 months ago by dadub

Hello everybody and thank you in advance for your help,

I use a datatable for my laravel site.

I have this error message :

DataTables warning: table id=example1 - Ajax error. For more information about this error, please see

and this error in my web console (firefox) :

Blocking of a cross-origin request: the “Same Origin” policy does not allow consulting the remote resource located on .json. Reason: The "x-csrf-token" header is not allowed according to the "Access-Control-Allow-Headers" header of the CORS request pre-check response.

This is the controller code :

        if($request->ajax()) {
            $query = Drug::with('drug_family','routes','atc','user')->select('drugs.*');

        return DataTables::eloquent($query)->toJson();
        return view('errors.layout');


I think I don't have any problem in my code, because with php artisan serve, I can display the datatable.

With MAMP (in local) I cannot display it.

Do you think it's a problem of security ?

Do you have any idea to resolve it ?

Thank you in advance for your help.

Please sign in or create an account to participate in this conversation.