How to fix “Mixed Content:” error when making API calls to elasticsearch from react

大城市里の小女人 提交于 2019-12-08 06:57:02

问题


I am using the bitnami version of elasticsearch from firebase. I found out that it only connects to http and not https when i tried it using postman. My create-react-app is deployed to firebase and I am getting Mixed Content: error when I try to fetch data using the axios library.

Here id my code:

import axios from 'axios';

axios.get('http://xx.xxx.xx.xxx//elasticsearch/tasks/task/_search?default_operator=AND&q=*', {
    httpsAgent: agent,
    method: 'get',
    headers: {
        // 'Content-Type': 'application/json',
        'Authorization': 'Basic xxxxxxxxxx='
    }
});

and the error

Mixed Content: The page at 'https://xxx-xxxx.firebaseapp.com/tasks' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://xx.xxx.xx.xxx//elasticsearch/tasks/task/_search?default_operator=AND&q=*'. This content should also be served over HTTPS.

来源:https://stackoverflow.com/questions/49704791/how-to-fix-mixed-content-error-when-making-api-calls-to-elasticsearch-from-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!