How to force Laravel Project to use HTTPS for all routes?

  • 1: Open app/providers/AppServiceProvider.php.
  • 2: Then add the https code snippet to the boot method.
    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        if (config('app.env') == 'production') {
            URL::forceScheme('https');
    }
  • 3: Lastly run php artisan route:clear && composer dumpautoload to clear Laravel’s cached routes and cached Service Providers.