Search code examples
laravelheroku

How to fix This request has been blocked; the content must be served over HTTPS


I've just deployed an app on heroku and it's not rendering as expected. After checking the console I'm getting the below error. How do i fix this?

Mixed Content: The page at 'https://photography-web-by-alphy.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://photography-web-by-alphy.herokuapp.com/css/style.css'. This request has been blocked; the content must be served over HTTPS.


Solution

    1. I used secure asset helper function. <link rel="stylesheet" href="{{ secure_asset('css/style.css') }}">

    2. I updated the APP_URL in the .env file from http to https. Then in the Config Vars on heroku I added the KEY to APP_URL and the value I provided the same value of the APP_URL from the .env then redeployed app and it now worked fine with no error!