From 551e9f7740735337fdc5f3dec60aa03c110d5985 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 18 Feb 2021 12:36:17 +0100 Subject: [PATCH] Use dotapps proxy --- index.html | 53 ++++++++--------------------------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/index.html b/index.html index 07b162f55..dc7da5669 100644 --- a/index.html +++ b/index.html @@ -192,53 +192,16 @@ return response; } - function checkUpCors (url, { contents, status: { content_length, error } }) { - // has an error from the CORS proxy - if ( - error && - (error.code !== 'UNABLE_TO_VERIFY_LEAF_SIGNATURE') - ) { - console.log(`${url} has an retrieval error`) - - return false; - } - - // has actual content or it has a refresh - if ( - (content_length < 100) && - !contents.includes(' console.log(url, response)) - .catch((error) => console.error(url, error)); + try { + await fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' }); - return fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' }) - .then(() => - fetchTimeout(`https://api.allorigins.win/get?url=${encodeURIComponent(url)}`) - .then((response) => response.json()) - .then((json) => checkUpCors(url, json)) - .catch(() => true) - ) - .catch(() => false); + const response = await fetchTimeout(`https://proxy.dotapps.workers.dev/?${url}`, { follow: 'error' }); + + return response.status === 200; + } catch (error) { + return false; + } } async function getBalance (key) {