如何修复从 React 对 Elasticsearch 进行 API 调用时的“混合内容:”错误

2024-05-12

我正在使用 firebase 的 elasticsearch 的 bitnami 版本。我发现它只能连接到http并不是https当我使用邮递员尝试时。我的create-react-app已部署到 firebase,我得到Mixed Content:当我尝试使用获取数据时出错axios图书馆。

这是我的代码:

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='
    }
});

和错误

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.

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修复从 React 对 Elasticsearch 进行 API 调用时的“混合内容:”错误 的相关文章

随机推荐