You should put in your app/Providers/AppServiceProvider.php:
public function boot(): void { if (env('APP_ENV') !== 'local') { URL::forceScheme('https'); } }
And include URL class
use Illuminate\Support\Facades\URL;
Whole AppServiceProvider:
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\URL; class AppServiceProvider extends ServiceProvider { /** * Register any application services. */ public function register(): void { // } /** * Bootstrap any application services. */ public function boot(): void { if (env('APP_ENV') !== 'local') { URL::forceScheme('https'); } } }