I was doing some cross-origin requests to Soundcloud's oEmbed and I noticed some strange behaviour.
When doing a request from my localhost, which is on a regular HTTP connection, everything worked fine. However, when the code got pushed on our HTTPS test server, I got the following error from my browser:
[blocked] The page at 'https://example.com' was loaded over HTTPS, but ran insecure content from https://www.soundcloud.com/oembed?url=https://soundcloud.com/gwatsky/pumped-up-kicks-remix&format=js&callback=JSON_CALLBACK: this content should also be loaded over HTTPS.
The request URL is //www.soundcloud.com/oembed?url=https://soundcloud.com/gwatsky/pumped-up-kicks-remix&format=js&callback=JSON_CALLBACK
. Note the "www.".
I tried specifying the protocol to HTTPS and removing/specifying the protocol in the url
parameter, but I kept getting the error.
In the end I removed the www.
from the URL and everything started working fine.
tl;dr Why is having www.
in this HTTPS URL considered a security risk?
https://www.soundcloud.com
tohttp://soundcloud.com
. Since https is dropped, your browser will complain of insecure content.www.soundcloud.com
is not the same assoundcloud.com
-- browsers and SSL certs are very strict about this. (And there are right and wrong ways to configure servers to handle these discrepancies. Sometimes mistakes, like a faulty 301 redirect, cause errors like this.)