I am working on a project that requires a secure connection.
I can set the route, uri, asset to use 'https' via:
Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']);
url($language.'/index', [], true)
asset('css/bootstrap.min.css', true)
But setting the parameters all the time seems tiring.
Is there a way to force all routes to generate HTTPS links?
Here are several ways. Choose most convenient.
Configure your web server to redirect all non-secure requests to https. Example of a nginx config:
Set your environment variable
APP_URL
using https:Use helper secure_url() (Laravel5.6)
Add following string to AppServiceProvider::boot() method (for version 5.4+):
Update:
Implicitly setting scheme for route group (Laravel5.6):
Add this to your .htaccess code
Replace www.yourdomain.com with your domain name. This will force all the urls of your domain to use https. Make sure you have https certificate installed and configured on your domain. If you do not see https in green as secure, press f12 on chrome and fix all the mixed errors in the console tab.
Hope this helps!
in app/Providers/AppServiceProvider.php
try this - it will work in RouteServiceProvider file
Place this in the AppServiceProvider in the boot() method
You can set
'url' => 'https://youDomain.com'
inconfig/app.php
or you could use a middleware class Laravel 5 - redirect to HTTPS.