Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iagorios's avatar

URL::forceSchema not working before login

I'm using URL::forceSchema('https') to force SSL on my Laravel 5.3 application. However, it only works after login (even the login page isn't being covered with https).

I'm also using TrustedProxy and I'm hosting my application on Heroku.

0 likes
6 replies
tykus's avatar

On Heroku, you can have your URI rewrite to https before hitting Laravel if you reference the following config in your Procfile:

// apache_app.conf
DirectoryIndex index.php index.html index.htm

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=307]
nipun's avatar

@iagorios thanks for the answer. I had an issue with an Invalid Signature in Laravel 8.0 and this helped me to fix it. So tested with Laravel 8.0.

rustedchip's avatar

@iagorios thanks, it is the best way that i found to fix it, I just changed env('APP_ENV') === 'production' for env('PROXY_SCHEMA') === 'https.

Please or to participate in this conversation.