I'm pretty sure that the path is generated with the help of your URL-setting.
Try checking your .env file. Maybe you have defined your URL as something like URL=http://yoursite.com? In that case, you can just change http to https :-)
How to apply HTTPS to the helpers asset and url
Hi. I am using L5.2 and after I added the HTTPS protocol using CloudFlare, I have problems with the assets path and the links.
Before I was using the helpers as follows:
{{ asset('js/my_script.js') }}
{{ asset('css/my_styles.css') }}
But the helpers generate a full path with HTTP instead of HTTPS. To correct that I add a second parameter (TRUE to use a secure path). Since I work locally I also need to set the 2nd parameter as FALSE and just use TRUE in production.
To achive that I have the following:
{{ asset('js/my_script.js', env('REDIRECT_HTTPS'))) }}
{{ asset('css/my_styles.css', env('REDIRECT_HTTPS'))) }}
And that works. But, I would have to modify all my blades.
There is a more simple way to do it? Or how I can override the helpers? I want to set a default value to the 2nd parameter (my env variable).
Thanks in advance.
I finally found a solution:
<?php
namespace App\Providers;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(UrlGenerator $url)
{
if(env('REDIRECT_HTTPS'))
{
$url->forceSchema('https');
}
}
Thanks to @jekinney for post this solution in https://laracasts.com/discuss/channels/laravel/mixed-content-issue-content-must-be-served-as-https
Please or to participate in this conversation.