diff --git a/src/config/api.ts b/src/config/api.ts index beb8bf4..4b96e77 100644 --- a/src/config/api.ts +++ b/src/config/api.ts @@ -1,4 +1,14 @@ -export const API_MODE = import.meta.env.VITE_API_MODE as "tailscale" | "local" | "ip"; +const hostname = window.location.hostname; +console.log("Current hostname:", hostname); +let API_MODE: "tailscale" | "local" | "ip"; + +if (hostname.includes("ts.net")) { + API_MODE = "tailscale"; +} else if (hostname === "localhost") { + API_MODE = "local"; +} else { + API_MODE = "ip"; +} export const API_ROOT = { tailscale: import.meta.env.VITE_API_URL_TAILSCALE, @@ -6,8 +16,6 @@ export const API_ROOT = { ip: import.meta.env.VITE_API_URL_IP, }; -console.log(API_ROOT) - export const BASE_URL = API_ROOT[API_MODE]; export const API_ENDPOINTS = {