Last Updated: September 30, 2021
·
12.89K
· eresendez

Mixed content issue - Content must be served as HTTPS in Laravel

I want to remember this:

When changing from http to https, it's possible to get the problem Mixed content issue - Content must be served as HTTPS.

So, first modify APP_URL in the .env file, if we use the assets helper, this shouldn't give any problem with the URL.

APP_URL=https://mydomain.com

Finally, add the following to the beginning of api.php or web.php:

if (App::environment('production')) {
    URL::forceScheme('https');
}

1 Response
Add your response

You can follow this guide to know how to force laravel https to redirect. You can basically use middleware class to enable it. Or you can do it through .htaccess file.

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#laravel
#php
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside