Edit
I can't really find a way to generate a secure URL from route name.
To get a full URL, I use
echo route('my_route_name');
But what to do, if I want a URL with https?
Actually turns out, that laravel doesn't care if url is secure or not, because it generates based on the current url. If you're on https page, route()
will return secure url. If on http, then http://
url
The problem was, that Laravel didn't detect that https was enabled, which was due to faulty server configuration.
You can check if Laravel sees the current connection as https by calling Request::isSecure();
For those who are using Laravel behind a load balancer or other proxy,
Request::isSecure()
will always return false, unless you trust theX-Forwarded-Proto
header from your proxy server. See: Laravel Tricks - Fix SSL in Laravel 4+@AdamLink God damn it, thank you so much. I searched for hours for this. I shall add some Google Keywords now in this comment: Laravel http https nginx reverse proxy, laravel route relative url https.
In my experience using Laravel 5.2 on XAMPP/Windows does not generate https URL's with
route()
if the request uses https. I noticed there's noHTTPS
entry in$_SERVER
so the protocol is not correctly detected.Laravel 5.3 does not detect HTTPS even in Linux.
@tirtakeniten check your .env file, what is the domain URL specified? It should be with https, not http