We will see how to force the routes created with the url() and URL::to() helpers to use HTTPS instead of HTTP in Laravel 5.2 without modifying all our views one by one, for this we will go to the file:
\App\Providers\AppServiceProvider.php
where within the boot() function we have to add the following code:
if (\App::environment('production')) { \URL::forceSchema('https'); }
In this case we are first checking if in our .env file we have set the environment as production, if this is the case it will force the use of HTTPS in the routes created with the url() and URL::to() helpers.
That's all, I hope it helps more than one
Tested in Laravel 5.1 and 5.2
Take your time to understand each concept before moving on to the next one.
Practice the examples in your own development environment for better understanding.
Don't hesitate to review the additional resources mentioned in the article.
Page loaded in 22.81 ms