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.
This commit is contained in:
Luke Watts 2022-10-22 15:05:59 +01:00
parent 7ef383d1f6
commit d1dca5a1f1
No known key found for this signature in database

View file

@ -39,7 +39,9 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
if (preg_match("/^https/", env('APP_URL')) || env('APP_ENV') === 'production') {
URL::forceScheme('https'); URL::forceScheme('https');
}
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Paginator::useBootstrap(); Paginator::useBootstrap();
Avatar::observe(AvatarObserver::class); Avatar::observe(AvatarObserver::class);