Skip to content

Instantly share code, notes, and snippets.

@ilhamsj
Last active July 13, 2023 02:08
Show Gist options
  • Save ilhamsj/819369a56bb983eac018c5f4e04cda50 to your computer and use it in GitHub Desktop.
Save ilhamsj/819369a56bb983eac018c5f4e04cda50 to your computer and use it in GitHub Desktop.
Force HTTPS laravel on heroku

Force HTTPS laravel on heroku

add this line after RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

app\Http\Middleware\TrustProxies.php

Before
protected $proxies;

After
protected $proxies = "*";

Documentation https://laravel.com/docs/5.8/requests#configuring-trusted-proxies

@luqman-v1
Copy link

thank worked on my heroku

@benisi
Copy link

benisi commented Jul 7, 2021

Thanks, nice!

@usuga1931
Copy link

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment