Generating secure https URL

We will see how to generate secure https URL from the route. By adding

URL::force Schema(‘https’);
you can generate secure https URL. This is applicable for Laravel version 4.2 to Laravel version 5.3.

For versions above 5.4 add
URL::forScheme(‘https’)
in the boot method of AppServiceProvider file. The forceSchema changed to forceScheme.

Include

use Illuminate\Support\Facades\URL;
at the top of the file.

Laravel doesn’t care if the url is secure or not because it generates based on current url. If you add.
Request::isSecure();
You can check if Laravel sees that the current connection is https. If you are using Laravel behind a load balancer or proxy the Request::isSecure(); will always return false.