My 2 cents regarding this issue.
I have a project hosted on one domain that works flawlessly.
I need to make it international so I am cloning the master branch to a new branch, making some necessary text changes and deploying new site (new domain) with code from the new branch.
Everything works fine, except 1 ajax call (api route) that gets blocked due to Mixed content.
First things first, I checked these 3 things:
- I check in the Network tab in dev tools and it is actually loaded through https.
- I open the file directly in browser and it is https.
- I try to open it as http:// and it automatically redirects to https://
This is very strange because the 2 domains are both using Cloudflare and their backend setup is identical, the code is the same (only text changes for the new one) yet for the new setup there is console error for 1 specific api route, an all others (some 20+ ajax requests across the page) work just fine. They are even using the same function to make the Ajax request, so it is definitely not a configuration error.
After doing some investigation I found out the issue:
The call that was 'buggy' was ending in /
. For example, all other calls were made to:
https://example.com/api/posts
https://example.com/api/users
And this particular one was making requests to
https://example.com/api/todos/
The slash at the end was making it fail with mixed content issue. I am not sure why this is causing issue and how it isn't an issue on the original site (since there the same ajax call works just fine), but it definitely fixed my issue.
If I figure out what caused the /
to fail so miserably, I will post an update.
https://example.com/script.js
(that is, the https version of the URL it’s reporting)? Regardless, if you puthttps://example.com/script.js
in your browser address bar, does it resolve or does it instead just redirect tohttp://example.com/script.js
(non-https)? – sideshowbarkerhttp
URLs tohttps
without checking to see if they redirect. I’m not sure if there’s a good answer yet at Stackoverflow about how to catch that, so I’ll try to formulate one right now and add it as answer so we have one here. – sideshowbarker