If you are on Heroku you may have noticed that when you have pagination links it comes out over HTTP. This is a problem because when you try to access that page, you get a Mixed Content error because those links are not in HTTPS. How do you solve this?
Asked
Active
Viewed 3,446 times
1
-
Check what is value of `APP_URL` in `.env` file. – Tpojka Jan 08 '19 at 05:59
2 Answers
10
To solve this all you have to do is go into AppServiceProvider.php and in the boot method add the following: $this->app['request']->server->set('HTTPS','on');

Maidul I
- 133
- 2
- 10
-
Can i mixed the solution? I have forceScheme set, trust all proxies set and your solution. The rest of the links generated just fine (with HTTPS) except pagination. I'm behind load balancer that terminates the SSL btw. – Zaiman Noris May 08 '20 at 02:37
4
This is a side-effect of Heroku's load balancing system. Heroku sets a X-Forwarded-Proto
header, but Laravel needs some minor configuration to process it properly. This is handled by the fideloper/proxy
package (which is built into Laravel as of v5.5). First, publish the config file:
php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
Then, in the resulting config/trustedproxy.php
file:
'proxies' => '*',
Your apps should correctly reflect the HTTP/HTTPS status now. (You'll also get the correct IP addresses for your users instead of the internal IPs of Heroku's load balancers, as an additional bonus.)

ceejayoz
- 176,543
- 40
- 303
- 368
-
this is useful if you have ssl for load balancer and your app is running on port 80, thank you man client - SSL - load balancer - 80 - app – Ugur Kazdal Mar 12 '21 at 14:00
-
1