change default cors url

This commit is contained in:
creeper123123321 2022-08-26 18:52:02 -03:00
parent 78d00ce31a
commit 505e5001c8
3 changed files with 13 additions and 11 deletions

View File

@ -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/";

View File

@ -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();

View File

@ -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<String> {
async function getIpAddress(cors: boolean): Promise<string> {
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<String> {
function getTokens(): Array<string> {
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}));
}