From ea34e448fd36d72439387b2c341b5cc4ad667af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 4 Sep 2026 11:43:27 +0200 Subject: [PATCH] fix: honour console URL scheme in VCS commit statuses and authorize link The VCS PR comment's build-log links already respected _APP_CONSOLE_URL_SCHEME, but the commit-status target URLs and the external-contributor authorize link did not, so on a root-scheme install they pointed at the legacy /console/project-{region}-{id} paths while the comment pointed at /projects/{id}. Gate all three on the same flag, and let GitAction read the hostname from the platform config it already receives instead of re-resolving _APP_CONSOLE_DOMAIN. Co-Authored-By: Claude Opus 5 (1M context) --- src/Appwrite/Deployment/GitAction.php | 9 ++++++--- .../Platform/Modules/VCS/Http/GitHub/Deployment.php | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Deployment/GitAction.php b/src/Appwrite/Deployment/GitAction.php index 8d709a0a2e..0d5d4103d6 100644 --- a/src/Appwrite/Deployment/GitAction.php +++ b/src/Appwrite/Deployment/GitAction.php @@ -50,10 +50,13 @@ final class GitAction default => $status }; - $hostname = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', '')); + $hostname = $platform['consoleHostname'] ?? ''; $region = $project->getAttribute('region', 'default'); - $segment = $isSite ? "sites/site-{$resource->getId()}" : "functions/function-{$resource->getId()}"; - $targetUrl = "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$segment}"; + $collection = $isSite ? 'sites' : 'functions'; + $type = $isSite ? 'site' : 'function'; + $targetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' + ? "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$collection}/{$type}-{$resource->getId()}" + : "{$protocol}://{$hostname}/projects/{$project->getId()}/{$collection}/{$resource->getId()}"; $name = $resource->getAttribute('name') . ' (' . $project->getAttribute('name') . ')'; $vcs->updateCommitStatus($repositoryName, $commitHash, $owner, $state, $message, $targetUrl, $name); diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php index b89364fb45..d9e123764f 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php @@ -165,7 +165,9 @@ trait Deployment $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $hostname = $platform['consoleHostname'] ?? ''; - $authorizeUrl = $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}"; + $authorizeUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' + ? $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}" + : $protocol . '://' . $hostname . "/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}"; $action = $isAuthorized ? ['type' => 'logs'] : ['type' => 'authorize', 'url' => $authorizeUrl]; @@ -565,7 +567,9 @@ trait Deployment } $owner = $vcs->getOwnerName($providerInstallationId, (int) $providerRepositoryId); - $providerTargetUrl = $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId"; + $providerTargetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' + ? $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId" + : $protocol . '://' . $hostname . "/projects/$projectId/$resourceCollection/$resourceId"; $vcs->updateCommitStatus($repositoryName, $providerCommitHash, $owner, 'pending', $message, $providerTargetUrl, $name); }