diff --git a/README.md b/README.md index 118609c..b9891cf 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,9 @@ return [ 'defaultStringLength' => 150, ], - 'middleware' => [ - 'forceHttps' => app()->environment('production'), + 'https' => [ + 'forceScheme' => app()->environment('production'), + 'middleware' => app()->environment('production'), ], 'paginator' => [ diff --git a/config/utils.php b/config/utils.php index 28fb66a..470203b 100644 --- a/config/utils.php +++ b/config/utils.php @@ -19,8 +19,9 @@ 'defaultStringLength' => 150, ], - 'middleware' => [ - 'forceHttps' => app()->environment('production'), + 'https' => [ + 'forceScheme' => app()->environment('production'), + 'middleware' => app()->environment('production'), ], 'paginator' => [ diff --git a/src/UtilsServiceProvider.php b/src/UtilsServiceProvider.php index 30f1f29..dd89624 100644 --- a/src/UtilsServiceProvider.php +++ b/src/UtilsServiceProvider.php @@ -33,7 +33,7 @@ public function boot() $this->bootModel(); $this->bootLocale(); $this->bootSchema(); - $this->bootMiddleware(); + $this->bootHttps(); $this->bootPaginator(); } @@ -89,16 +89,18 @@ private function bootSchema() } /** - * Bootstrap middleware. + * Bootstrap https. * * @return void */ - private function bootMiddleware() + private function bootHttps() { - if (config('utils.middleware.forceHttps')) { + if (config('utils.https.middleware')) { $kernel = $this->app->make(Kernel::class); $kernel->prependMiddleware(HttpsProtocolMiddleware::class); + } + if (config('utils.https.forceScheme')) { URL::forceScheme('https'); } } diff --git a/tests/CustomValuesTest.php b/tests/CustomValuesTest.php index 182c6e5..f05259c 100644 --- a/tests/CustomValuesTest.php +++ b/tests/CustomValuesTest.php @@ -27,8 +27,9 @@ protected function getEnvironmentSetUp($app) 'defaultStringLength' => null, ], - 'middleware' => [ - 'forceHttps' => true, + 'https' => [ + 'forceScheme' => true, + 'middleware' => true, ], 'paginator' => [