Skip to content

Commit adaa08a

Browse files
authored
Fix CORS proxy
1 parent 0a4ae24 commit adaa08a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

htmlpreview.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@
8888

8989
var fetchProxy = function (url, options, i) {
9090
var proxy = [
91-
//'https://cors.io/?',
92-
'https://jsonp.afeld.me/?url=',
91+
'https://thingproxy.freeboard.io/fetch/',
92+
'https://yacdn.org/serve/',
9393
'https://cors-anywhere.herokuapp.com/'
9494
];
9595
return fetch(proxy[i] + url, options).then(function (res) {
96-
if (!res.ok)
97-
throw new Error('Cannot load ' + url + ': ' + res.status + ' ' + res.statusText);
9896
return res.text();
9997
}).catch(function (error) {
10098
if (i === proxy.length - 1)
@@ -104,7 +102,10 @@
104102
};
105103

106104
if (url && url.indexOf(location.hostname) < 0)
107-
fetchProxy(url, null, 0).then(loadHTML).catch(function (error) {
105+
fetch(url).then(function (res) {
106+
if (!res.ok) throw new Error('Cannot load ' + url + ': ' + res.status + ' ' + res.statusText);
107+
return res.text();
108+
}).then(loadHTML).catch(function (error) {
108109
console.error(error);
109110
previewForm.style.display = 'block';
110111
previewForm.innerText = error;

0 commit comments

Comments
 (0)