I am using Laravel 7 and website is running on https but it shows all links to http.
i am using below code to redirect for all pages.
<a href="{{url('about')}}">About></a>
in config/app.php you should have a url entry to set like:
'url' => 'https://your-website.domain'
otherwise you can use the boot method of AppServiceProvider adding this:
\URL::forceScheme('https');
AppServiceProvider and inside the boot method (that you will see inside that file) add that line of codeI had the same issue when running a Laravel application behind an NGINX proxy and the communication internally was running via HTTP. So, the request reached Laravel as HTTP.
The solution from Alberto was fixing it. Here is the code I have added to the boot() method of the AppServiceProvider:
if (config('app.env') === 'production' || config('app.env') === 'staging') {
URL::forceScheme('https');
}
I am testing telegram bot with ngrok forwarding, and always edit APP_URL in my env file
and sometimes I testing local http://localhost:81
My solution in the boot() method of the AppServiceProvider
use Illuminate\Support\Facades\URL;
if (mb_strpos(env('APP_URL'), 'https') === 0) {
URL::forceScheme('https');
}
URL::forceScheme where Albert's code calls it unconditionally.