2017-02-19 2 views
0
fetch('https://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world') 
    .then(resp => resp.json()) 
    .then(json => console.log(json)) 

Ich habe versucht, meine Json Daten zu holen aus meiner gh-Seiten (gh-Seiten Access-Control-Allow-Origin ist *)HTTPS wird von Browser und meine Anfrage als HTTP requeset

Wodurch ich angesehen abgebrochen ist dies:

what code I use and what I get

und ich überprüft das Netzwerk-Panel in Chrome DevTool:

network panel in Chrome's devtool

Die HTTPS-Anfrage wird vom Browser abgebrochen, mein Abruf gilt als HTTP-Anfrage.

Warum und wie lösen dieses

curl https://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world -i 

erhalten:

HTTP/1.1 301 Moved Permanently 
Server: GitHub.com 
Content-Type: text/html 
Location: http://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world/ 
Access-Control-Allow-Origin: * 
Expires: Mon, 20 Feb 2017 07:08:43 GMT 
Cache-Control: max-age=600 
X-GitHub-Request-Id: F932:2F9ED:6B263C9:9012708:58AA93A3 
Content-Length: 178 
Accept-Ranges: bytes 
Date: Mon, 20 Feb 2017 06:58:43 GMT 
Via: 1.1 varnish 
Age: 0 
Connection: keep-alive 
X-Served-By: cache-nrt6121-NRT 
X-Cache: MISS 
X-Cache-Hits: 0 
X-Timer: S1487573923.394396,VS0,VE179 
Vary: Accept-Encoding 
X-Fastly-Request-ID: 7acb3e168a104bffe672ee2c77215cd750197a3f 

<html> 
<head><title>301 Moved Permanently</title></head> 
<body bgcolor="white"> 
<center><h1>301 Moved Permanently</h1></center> 
<hr><center>nginx</center> 
</body> 
</html> 

Anfrage https wird umleiten

curl http://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world -i 

wird auf http erhalten:

HTTP/1.1 301 Moved Permanently 
Server: GitHub.com 
Content-Type: text/html 
Location: https://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world 
X-GitHub-Request-Id: C9E0:786B:3CE9A28:5028A16:58AA941A 
Content-Length: 178 
Accept-Ranges: bytes 
Date: Mon, 20 Feb 2017 07:00:43 GMT 
Via: 1.1 varnish 
Age: 0 
Connection: keep-alive 
X-Served-By: cache-nrt6122-NRT 
X-Cache: MISS 
X-Cache-Hits: 0 
X-Timer: S1487574043.118608,VS0,VE179 
Vary: Accept-Encoding 
X-Fastly-Request-ID: d4377ad8a08c54c1328558908b91941739f27279 

<html> 
<head><title>301 Moved Permanently</title></head> 
<body bgcolor="white"> 
<center><h1>301 Moved Permanently</h1></center> 
<hr><center>nginx</center> 
</body> 
</html> 

und HTTP-Anforderung wird

Antwort

1

Eine Anforderung an https://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world erzeugt ein 301 ("Dauerhaft verschoben") zu http://vanishingdante.github.io/gh-pages-blog-api/2017/02/11/bye-world/, auf HTTPS reddirect werden, die, um Probleme zu verursachen.

In this blog post wird darauf hingewiesen, dass Sie die HTTPS-Unterstützung in den Einstellungen für die Website manuell aktivieren müssen, wenn Ihre Website bereits vor dem 15. Juni 2016 vorhanden war.

+0

Aber meine Website wurde vor 9 Tagen erstellt, und die HTTPS-Erzwingung ist aktiviert – Vanis

Verwandte Themen