webpack dev server 混合内容错误

webpack dev server mixed content error

我是 运行 Cloud9 上使用 webpack-dev-server 的基于 React 的网站,因此它通过 https 提供内容。问题是,当我尝试向外部 http link 发出一些 ajax(网络)请求时,它会出现以下错误:

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

webpack配置有什么技巧可以从http请求数据吗?

可能没有webpack-dev-server的解决方案,但是下面的nodejs不错

app.use(function(req, res, next) {
    if (req.headers['x-forwarded-proto'] == 'https') {
        res.redirect('http://' + req.hostname + req.url);
    } else {
        next();
    }
});