laravel-datatables
laravel-datatables copied to clipboard
Loads all the data from database on server but works well on local environment.
Summary of problem or feature request
I have used this package for a quite a long time but I am getting a weird issue on a live server. On local environment the response from the controller is correct and response data count is correct for whatever I put in pageLength value. But in Live Server, it is fetching all 20,000+ records.
If I use 10 as a page length then the first query is fast i.e normal, but when i paginate to page 2, again all the records are fetched. and the response size is again huge.
Local - Response Size is 7kb

Live - Response Size is 80mb

-- BlogController.php
$articles = Article::query()
->with(['media', 'editor', 'categories', 'author', 'views'])
->select('articles.*')
->$scope();
return DataTables::of($articles)
->editColumn('title', function ($data) {
return '<div>' . $data->title . '</div>';
})
->addIndexColumn()
->rawColumns(['title'])
->make(TRUE);
-- Blade File
$(document).ready(() => {
let articleTable = $("#article-tables").DataTable({
processing: true,
serverSide: true,
"scrollX": true,
"scrollY": false,
responsive: false,
paging: true,
pageLength: 50,
ajax: {
url: "{{ route('api.cms.article.datatables') }}",
type: "GET",
},
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false},
{data: 'title', name: 'title', orderable: false},
],
"fnDrawCallback": function () {
initSwitchToggler()
initTooltip()
initPopOver()
}
});
});
- Operating System : Oracle Linux (Live) | MacOs (Local)
- PHP Version : 8.0.19
- Laravel Version : 8.83
- Laravel-Datatables Version: 1.5
Looks like double encoding is happening in your url and it is server configuration issue. See https://github.com/yajra/laravel-datatables/issues/1210
I tried changing .htaccess file and issue still persist.
RewriteRule ^(.*)/$ /$1 [L,R=301,NE]
Tried and compared nginx configuration with all commented codes, still no success 😥
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.