Laravel 8 Pagination issue on AWS EC2 instance
Hi, I want to share the experience and solution that I found for one of my Laravel 8 projects.
Issue:
The project was working fine on the local environment but after pushing on the live AWS EC2 instance the problem started to occur on pagination. Those results for which the pagination was required the first page was loading perfectly fine, but once click on the second or third page it started to break the application and the page doesn’t load.
Solution:
After hunting down the whole internet and trying different solutions I found one that worked well for me.
First of all, it took me a while to diagnose the actual issue because there was nothing that I can do in the local environment to test or debug it as the whole project was working perfectly fine. Then I came to know that the whole website was loading on the HTTPS while the next pages of the pagination were loading on HTTP which was actually causing this issue.
Then I tried adding the following piece of code in the app/Providers/AppServiceProvider.php
to the boot methodpublic function boot()
{
$this->app['request']->server->set('HTTPS','on');
}
Hope it will be helpful for you!
Cheers!