From bb2fce75ee5a63f2b61c7e75dfdcfab9c5b7c05c Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Thu, 17 Apr 2025 08:22:51 -0600 Subject: [PATCH] update check to use location --- src/pages/parts/settings/SetupPart.tsx | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/pages/parts/settings/SetupPart.tsx b/src/pages/parts/settings/SetupPart.tsx index ebb50a98..f31f50a0 100644 --- a/src/pages/parts/settings/SetupPart.tsx +++ b/src/pages/parts/settings/SetupPart.tsx @@ -19,8 +19,40 @@ import { Heading3 } from "@/components/utils/Text"; import { conf } from "@/setup/config"; import { useAuthStore } from "@/stores/auth"; +const getRegion = (): string | null => { + if (typeof window === "undefined") return null; + try { + const regionData = window.localStorage.getItem("__MW::region"); + if (!regionData) return null; + const parsed = JSON.parse(regionData); + return parsed?.state?.region || null; + } catch { + return null; + } +}; + +const getBaseUrl = (): string => { + const region = getRegion(); + switch (region) { + case "us-east": + return "https://fed-api-east.pstream.org"; + case "us-west": + return "https://fed-api-west.pstream.org"; + case "south-america": + return "https://fed-api-south.pstream.org"; + case "asia": + return "https://fed-api-asia.pstream.org"; + case "europe": + return "https://fed-api-europe.pstream.org"; + default: + return "https://fed-api-east.pstream.org"; + } +}; + +const BASE_URL = getBaseUrl(); + const testUrl = "https://postman-echo.com/get"; -const febboxApiTestUrl = "https://fed-api.pstream.org/movie/tt15239678"; +const febboxApiTestUrl = `${BASE_URL}/movie//tt0325980`; const sleep = (ms: number): Promise => { return new Promise((resolve) => {