Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack dev server mixed content error

I'm running React based website on Cloud9 using webpack-dev-server, so it serves content over https. The problem is that when I try to make some ajax (network) request to external http link, it gives the following error:

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.

Is there any trick for webpack configuration to make it possible request data from http?

like image 263
Rashad Ibrahimov Avatar asked Feb 14 '17 13:02

Rashad Ibrahimov


1 Answers

Probably there is no solution for webpack-dev-server, but the following is good for nodejs

app.use(function(req, res, next) {
    if (req.headers['x-forwarded-proto'] == 'https') {
        res.redirect('http://' + req.hostname + req.url);
    } else {
        next();
    }
});
like image 51
Rashad Ibrahimov Avatar answered Oct 30 '22 11:10

Rashad Ibrahimov