2

I am using the ->paginate(20); function on my query but the only problem is that it will return http and not https

Eg: "next_page_url":"http://www.mysite"

I have tried to force my app to use https by adding this in AppServiceProvider

public function boot()
    {
        if (!\App::environment('local')) {
            \URL::forceSchema('https');
        }
    }

So have can I force Laravel to return all links in https?

user2722667
  • 8,195
  • 14
  • 52
  • 100
  • possible duplicate http://stackoverflow.com/questions/19967788/laravel-redirect-all-requests-to-https – Beginner Nov 29 '16 at 01:00
  • This is not a dupe. There are specific bugs related to laravel pagination that do not apply to the rest of the url/routing logic. Please do not mark questions as dupes if you do not actually know that they are dupes due to actual experience in the specific matter being asked. – mopsyd Jun 20 '18 at 21:12

1 Answers1

2

I got it working by setting path on the paginator:

Laravel 5.1+:

$results->paginate();
$results->setPath(''); // Will return ?page=2
// OR
$results->setPath(config('app.url')); // Will return website URL defined in .env file + ?page=

Before Laravel 5.1:

$results->paginate();
$results->setBaseUrl('https://' . Request::getHttpHost() . '/' . Request::path());

I don't believe its the best solution, but fixed my problem.

Source 1
Source 2