laravel-datatables icon indicating copy to clipboard operation
laravel-datatables copied to clipboard

Loads all the data from database on server but works well on local environment.

Open anuzpandey opened this issue 3 years ago • 2 comments

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 Screen Shot 2022-05-20 at 3 14 26 PM

Live - Response Size is 80mb image

-- 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

anuzpandey avatar May 20 '22 09:05 anuzpandey

Looks like double encoding is happening in your url and it is server configuration issue. See https://github.com/yajra/laravel-datatables/issues/1210

yajra avatar May 20 '22 09:05 yajra

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 😥

anuzpandey avatar May 20 '22 10:05 anuzpandey

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 10 '22 02:10 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Oct 18 '22 00:10 github-actions[bot]