Laravel Axios Mixed Content Error on AWS

Posted 1 year ago by UnFukWitAble

Hi guys,

I am moving app into production. Everything seems to work fine on http; however, when using https I get mixed content errors from axios.

Mixed Content: The page at 'https://my-website.com/admin/accounts' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.my-website.com/api/accounts/paginate'. This request has been blocked; the content must be served over HTTPS.

Things I have tried.

In .env

APP_ENV=production
APP_URL=https://my-website.com

In config/app.php

'url' => env('APP_URL', 'https://my-website.com'),

In app/Providers/AppServiceProvider.php boot() method

if($this->app->environment('production')) {
    \URL::forceScheme('https');
}

I have also tried editing default axios baseUrl in resources/assets/js/bootstrap.js

window.axios.defaults.baseURL = 'https://www.my-website.com';

When i visit the end point from https (like below) everything works fine and the json data shows up.

https://my-website.com/api/accounts/paginate

I can not figure out how to get axios to use https. Any help would be appreciated, currently halting move to production.

Please sign in or create an account to participate in this conversation.