5

WebPack-dev-server kullanarak Cloud9'da React tabanlı web sitesini çalıştırıyorum, böylece https üzerinden içerik sunuyor. webpack yapılandırma http bunu mümkün isteği verisine yapmak için herhangi bir hilewebpack dev server karma içerik hatası

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.

var mı: Sorun dış http bağlantısını bazı ajax (ağ) isteği yapmaya çalıştığınızda, aşağıdaki hata veriyor bu?

cevap

1

Muhtemelen webpack-dev-sunucu için bir çözüm yoktur, ancak aşağıdaki nodejs

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