fix: use redirect page for all platforms and fallback to regular subscription URL

- Always route deep links through redirect.html instead of splitting
  mobile/desktop paths, fixing Telegram Mini App WebView limitation
  with custom URL schemes (happ://, clash://, etc.)
- Fallback to regular subscriptionUrl instead of crypto resolvedUrl
  for subscriptionLink buttons
This commit is contained in:
c0mrade
2026-02-05 16:42:52 +03:00
parent 053b904c24
commit 5111b63f2e

View File

@@ -334,16 +334,10 @@ export default function Connection() {
resolved = resolveUrl(resolved); resolved = resolveUrl(resolved);
} }
const isMobilePlatform = detectedPlatform === 'ios' || detectedPlatform === 'android'; // Always use redirect page — opens in external browser where custom URL schemes work.
// Solves Telegram Mini App WebView limitation with custom schemes (happ://, clash://, etc.)
const finalUrl = `${window.location.origin}/miniapp/redirect.html?url=${encodeURIComponent(resolved)}&lang=${i18n.language || 'en'}`;
// Desktop: deep links need redirect page (browser can't handle custom schemes directly)
// Mobile: system browser handles custom schemes natively
const finalUrl = isMobilePlatform
? resolved
: `${window.location.origin}/miniapp/redirect.html?url=${encodeURIComponent(resolved)}&lang=${i18n.language || 'en'}`;
// In Telegram Mini App — sdkOpenLink opens URL in system browser,
// where custom URL schemes work (WebView itself can't handle them)
if (isTelegramWebApp) { if (isTelegramWebApp) {
try { try {
sdkOpenLink(finalUrl, { tryInstantView: false }); sdkOpenLink(finalUrl, { tryInstantView: false });
@@ -355,7 +349,7 @@ export default function Connection() {
window.location.href = finalUrl; window.location.href = finalUrl;
}, },
[detectedPlatform, isTelegramWebApp, i18n.language, resolveUrl], [isTelegramWebApp, i18n.language, resolveUrl],
); );
const handleConnect = (app: AppInfo) => { const handleConnect = (app: AppInfo) => {
@@ -652,8 +646,8 @@ export default function Connection() {
getBaseTranslation('openApp', 'subscription.connection.openLink'); getBaseTranslation('openApp', 'subscription.connection.openLink');
if (btn.type === 'subscriptionLink') { if (btn.type === 'subscriptionLink') {
// Use app deepLink first, fallback to resolved button URL // Use app deepLink first, fallback to regular subscription URL
const deepLink = currentApp?.deepLink || btn.resolvedUrl; const deepLink = currentApp?.deepLink || appConfig.subscriptionUrl;
if (!deepLink || !isValidDeepLink(deepLink)) return null; if (!deepLink || !isValidDeepLink(deepLink)) return null;
const subBtnSvg = getSvgHtml(btn.svgIconKey); const subBtnSvg = getSvgHtml(btn.svgIconKey);
return ( return (