Why won't Axios use the same protocol

Viewed 595

I'm getting the error:

Mixed Content: The page at 'https://mywebsite.io/content_library' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://mywebsite.io/api/blog_posts/'. This request has been blocked; the content must be served over HTTPS.

In my axios request, I'm simply using relative urls, '/api/blog_posts/` so why isn't axios sending the requests with https instead of http?

1 Answers

I had the same error, my site is served with haproxy over https and the nginx server just runs http I don't think its axios related but a general problem for XmlHttpRequest?

However, i've set: Content-Security-Policy to upgrade-insecure-requests, which fixes this problem at least on chrome. But I think microsoft edge does not support this.

So, the better fix should be to use an absoluteURL in axios with https.

I still don't get, why axios/browser is using http here...

Related