From e8454a93a8b442414eb76cab88d87a458bd978de Mon Sep 17 00:00:00 2001 From: hashbro Date: Tue, 6 Oct 2026 07:46:19 +0800 Subject: [PATCH] fix: patch ShellConfigEndpoint + ShellWebsiteURL in Info.plist Root cause: Info.plist contains ShellConfigEndpoint that overrides the runtime-constructed config URL. Without patching this, the app still requests shenma.my/api/ios-shell/config. Fix: patch ShellConfigEndpoint to https:///api/ap/config?a= and ShellWebsiteURL to the channel's h5_url if set. --- app/Services/AppPackageService.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Services/AppPackageService.php b/app/Services/AppPackageService.php index 5aa60fe..ccaeb12 100644 --- a/app/Services/AppPackageService.php +++ b/app/Services/AppPackageService.php @@ -79,7 +79,7 @@ class AppPackageService } // 2. Patch Info.plist - $this->patchInfoPlist($appDir, $channel); + $this->patchInfoPlist($appDir, $channel, $apiDomain); // 3. Generate icons from logo if ($logoPath && file_exists($logoPath)) { @@ -134,7 +134,7 @@ class AppPackageService } } - private function patchInfoPlist(string $appDir, Channel $channel): void + private function patchInfoPlist(string $appDir, Channel $channel, string $apiDomain): void { $plistPath = $appDir.'/Info.plist'; $xml = file_get_contents($plistPath); @@ -162,6 +162,23 @@ class AppPackageService $xml, ); + // Replace ShellConfigEndpoint (config API URL) + $configEndpoint = 'https://'.$apiDomain.'/api/ap/config?a='.$channel->channel_id; + $xml = preg_replace( + '#ShellConfigEndpoint\s*[^<]*#', + 'ShellConfigEndpoint'.htmlspecialchars($configEndpoint).'', + $xml, + ); + + // Replace ShellWebsiteURL (fallback WebView URL) + if ($channel->h5_url) { + $xml = preg_replace( + '#ShellWebsiteURL\s*[^<]*#', + 'ShellWebsiteURL'.htmlspecialchars($channel->h5_url).'', + $xml, + ); + } + file_put_contents($plistPath, $xml); }