From d1dca5a1f1348052ce5b5d061bbd5d7251651f9c Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Sat, 22 Oct 2022 15:05:59 +0100 Subject: [PATCH] fix: add opt of forceScheme(https) When running the application locally with APP_URL=http://localhost it is unexpected for all route URLs returned by `route('route-name')` to use the https prefix. Configuring SSL for your local environment should not be a required step to development locally. The new logic checks the configured URL for presence of https:// OR that this the application is running in a production environment. --- app/Providers/AppServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2272efa5..e1712b1d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -39,7 +39,9 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - URL::forceScheme('https'); + if (preg_match("/^https/", env('APP_URL')) || env('APP_ENV') === 'production') { + URL::forceScheme('https'); + } Schema::defaultStringLength(191); Paginator::useBootstrap(); Avatar::observe(AvatarObserver::class);