3

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?

2
  • possible duplicate stackoverflow.com/questions/19967788/… Commented Nov 29, 2016 at 1: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. Commented Jun 20, 2018 at 21:12

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.