From 94d08f1886d732b6583b59bda764eaa0522a9706 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Sat, 18 Jul 2020 06:33:00 +0100 Subject: [PATCH] Trust Heroku proxies This commit also forces the environment into HTTPS when in production. --- app/Http/Middleware/TrustProxies.php | 4 ++-- app/Providers/AppServiceProvider.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index ee5b595..085cdb5 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -12,12 +12,12 @@ class TrustProxies extends Middleware * * @var array|string */ - protected $proxies; + protected $proxies = "*"; /** * The headers that should be used to detect proxies. * * @var int */ - protected $headers = Request::HEADER_X_FORWARDED_ALL; + protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5c82792..aec3e77 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -33,5 +33,7 @@ class AppServiceProvider extends ServiceProvider Schema::defaultStringLength(191); User::observe(UserObserver::class); + + $this->app['request']->server->set('HTTPS', $this->app->environment() != 'local'); } }