From 868231adb135a421b5e462a650ad0be63b710543 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 28 Jan 2022 17:45:41 +0800 Subject: [PATCH] feat: drop deprecated app router --- src/LeanCloud/Client.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/LeanCloud/Client.php b/src/LeanCloud/Client.php index 30ed270..027f8ee 100644 --- a/src/LeanCloud/Client.php +++ b/src/LeanCloud/Client.php @@ -236,8 +236,17 @@ public static function getAPIEndPoint() { } else if ($url = getenv("LEANCLOUD_API_SERVER")) { return $url . "/" . self::$apiVersion; } else { - $host = AppRouter::getInstance(self::$appId)->getRoute(AppRouter::API_SERVER_KEY); - return "https://{$host}/" . self::$apiVersion; + $region = getenv("LEANCLOUD_REGION"); + $appIdPrefix = strtolower(substr(self::$appId, 0, 8)); + if ($region == "US") { + return "https://{$appIdPrefix}.lncldglobal.com" . self::$apiVersion; + } else if (str_ends_with(self::$appId, "-MdYXbMMI")) { + return "https://{$appIdPrefix}.lncldglobal.com" . self::$apiVersion; + } else if (str_ends_with(self::$appId, "-9Nh9j0Va")) { + return "https://{$appIdPrefix}.lc-cn-e1-shared.com" . self::$apiVersion; + } else { + return "https://{$appIdPrefix}.lc-cn-n1-shared.com" . self::$apiVersion; + } } }