From 505e5001c84045a966239658a9d970c1488eaded Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Fri, 26 Aug 2022 18:52:02 -0300 Subject: [PATCH] change default cors url --- src/main/resources/web/js/config.js | 2 ++ src/main/resources/web/js/page.js | 2 +- src/main/resources/web/js/page.ts | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/resources/web/js/config.js b/src/main/resources/web/js/config.js index fa5762d..83815a7 100644 --- a/src/main/resources/web/js/config.js +++ b/src/main/resources/web/js/config.js @@ -7,3 +7,5 @@ const azureClientId = "a370fff9-7648-4dbf-b96e-2b4f8d539ac2"; const whitelistedOrigin = [ "https://via.re.yt.nom.br" ]; +// Default CORS Proxy config +const defaultCorsProxy = "https://cors.re.yt.nom.br/"; \ No newline at end of file diff --git a/src/main/resources/web/js/page.js b/src/main/resources/web/js/page.js index 0548c2c..7dd0273 100644 --- a/src/main/resources/web/js/page.js +++ b/src/main/resources/web/js/page.js @@ -312,7 +312,7 @@ function authNotification(msg, yes, no) { }); } function defaultCors() { - return "https://crp123-cors.herokuapp.com/"; + return defaultCorsProxy || "https://cors.re.yt.nom.br/"; } function getCorsProxy() { return localStorage.getItem("viaaas_cors_proxy") || defaultCors(); diff --git a/src/main/resources/web/js/page.ts b/src/main/resources/web/js/page.ts index 158a9f1..d86eb37 100644 --- a/src/main/resources/web/js/page.ts +++ b/src/main/resources/web/js/page.ts @@ -63,7 +63,7 @@ $(() => { ohNo(); refreshAccountList(); - setInterval(refreshCorsStatus, 10 * 60 * 1000); // Heroku auto sleeps in 30 min + setInterval(refreshCorsStatus, 10 * 60 * 1000); refreshCorsStatus(); resetHtml(); }); @@ -282,14 +282,14 @@ function ohNo() { } // Util -function checkFetchSuccess(msg: String): (a: Response) => Response { +function checkFetchSuccess(msg: string): (a: Response) => Response { return (r: Response): Response => { if (!r.ok) throw r.status + " " + msg; return r; }; } -async function getIpAddress(cors: boolean): Promise { +async function getIpAddress(cors: boolean): Promise { return fetch((cors ? getCorsProxy() : "") + "https://ipv4.icanhazip.com") .then(checkFetchSuccess("code")) .then(r => r.text()) @@ -349,11 +349,11 @@ function authNotification(msg: string, yes: () => void, no: () => void) { } // Cors proxy -function defaultCors() { - return "https://crp123-cors.herokuapp.com/"; +function defaultCors(): string { + return defaultCorsProxy || "https://cors.re.yt.nom.br/"; } -function getCorsProxy() { +function getCorsProxy(): string { return localStorage.getItem("viaaas_cors_proxy") || defaultCors(); } @@ -639,20 +639,20 @@ function removeToken(token: string) { localStorage.setItem("viaaas_tokens", JSON.stringify(hTokens)); } -function getTokens(): Array { +function getTokens(): Array { return (JSON.parse(localStorage.getItem("viaaas_tokens")) || {})[wsUrl] || []; } // Websocket -function listen(token: String) { +function listen(token: string) { socket.send(JSON.stringify({"action": "listen_login_requests", "token": token})); } -function unlisten(id: String) { +function unlisten(id: string) { socket.send(JSON.stringify({"action": "unlisten_login_requests", "uuid": id})); } -function confirmJoin(hash: String) { +function confirmJoin(hash: string) { socket.send(JSON.stringify({action: "session_hash_response", session_hash: hash})); }