Laravel Mixed Content issue and broken stylesheet

03 Sep, 2020

Hey,

If you are facing any issue related with Mixed Content of your laravel project, here could one of the possible solution that recently I faced.

In my case, the entire stylesheet was broken and I got the following errors in the console-

Mixed content: load all resources via HTTPS to improve the security of your site.

Why it happened?

I was using asset() for declaring styles and scripts. The actual reason is the asset() won't handle https automatically. That's why it was happening.

How did I solve it?

In my .env file, I set the following lines-


APP_URL=https://myproject.test
ASSET_URL="${APP_URL}"

Here, I mainly added ASSET_URL that actually took the APP_URL data, that is following the https.\

Hope it will work for you also.

Thanks.

Hello. I’m Thouhedul Islam. Some people also know me as Suchi.

I am a Full-stack Developer. I love to play with PHP especially Laravel, JavaScript, MySql, and latest web technology. Currently, I am working for CartX as my day time job.

At night I love to solve problems for the community. I love to be active at Laracasts.