Skip to content

Commit

Permalink
fix: add opt of forceScheme(https)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thisislawatts committed Oct 23, 2022
1 parent 7ef383d commit d1dca5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d1dca5a

Please sign in to comment.