From 7d1121d83d91a98a5e3daa7d4951fab195da0ae4 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Tue, 15 Sep 2026 13:04:26 +0530 Subject: [PATCH] feat(console): build console links from _APP_CONSOLE_URL Drops _APP_CONSOLE_URL_SCHEME and the legacy /console/project-{region}-{id} link shapes. OAuth2 and magic URL defaults, router error CTAs, preview authorization, VCS commit statuses and PR comments, and the paused-webhook email now link to the console root routes on _APP_CONSOLE_URL, which defaults to the console domain over the configured protocol. The webhooks and jobs workers receive the variables the default is derived from. --- .env | 1 + app/config/platform.php | 2 + app/config/variables.php | 8 +-- app/controllers/api/account.php | 36 +++++------- app/controllers/general.php | 30 +++------- docker-compose.yml | 15 +++-- src/Appwrite/Deployment/GitAction.php | 7 +-- .../Modules/VCS/Http/GitHub/Deployment.php | 11 +--- src/Appwrite/Platform/Workers/Webhooks.php | 9 +-- src/Appwrite/Vcs/Comment.php | 8 +-- .../Account/AccountCustomClientTest.php | 4 +- tests/unit/Platform/Workers/WebhooksTest.php | 55 +------------------ 12 files changed, 52 insertions(+), 134 deletions(-) diff --git a/.env b/.env index a09c1da12d..86d469ccfc 100644 --- a/.env +++ b/.env @@ -28,6 +28,7 @@ _APP_OPTIONS_ROUTER_PROTECTION=disabled _APP_OPTIONS_ABUSE=disabled _APP_OPTIONS_ABUSE_INCREASED_LIMIT_PROJECTS=increased-limit-project _APP_CONSOLE_DOMAIN=localhost +_APP_CONSOLE_URL= _APP_CONSOLE_HOSTNAMES=localhost,appwrite.io,*.appwrite.io _APP_CONSOLE_SCHEMA=appwriteio _APP_CONSOLE_SESSION_ALERTS=enabled diff --git a/app/config/platform.php b/app/config/platform.php index 21aedaad98..7e4f99fdf2 100644 --- a/app/config/platform.php +++ b/app/config/platform.php @@ -19,6 +19,8 @@ if (\str_contains($functionsDomain, ',')) { return [ 'apiHostname' => System::getEnv('_APP_DOMAIN', 'localhost'), 'consoleHostname' => System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', 'localhost')), + // Console web app origin for links; it can live apart from the API host above + 'consoleUrl' => \rtrim(System::getEnv('_APP_CONSOLE_URL', (System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https') . '://' . System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', 'localhost'))), '/'), 'hostnames' => array_filter(array_unique([ System::getEnv('_APP_DOMAIN', 'localhost'), System::getEnv('_APP_CONSOLE_DOMAIN', 'localhost'), diff --git a/app/config/variables.php b/app/config/variables.php index 297a129fd7..d67f07d406 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -242,10 +242,10 @@ return [ 'filter' => '' ], [ - 'name' => '_APP_CONSOLE_URL_SCHEME', - 'description' => 'Console URL scheme used when the backend generates links to the console (OAuth callbacks, emails, error page CTAs, VCS comments). Set to \'root\' for the new console served at the root path (appwrite/new), or \'legacy\' for the older console served under the /console path prefix. The default value is \'legacy\'.', - 'introduction' => '2.0.0', - 'default' => 'legacy', + 'name' => '_APP_CONSOLE_URL', + 'description' => 'Origin of the Appwrite console web app, such as https://console.example.com, used when the backend generates links to the console (OAuth callbacks, emails, error page CTAs, VCS comments and commit statuses). Set it when the console is served on a different host than the API. When empty, links use _APP_CONSOLE_DOMAIN (or _APP_DOMAIN) over https, or over http when _APP_OPTIONS_FORCE_HTTPS is disabled.', + 'introduction' => '2.1.1', + 'default' => '', 'required' => false, 'question' => '', 'filter' => '' diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 4bad06ca4e..5c8d7ff94e 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -77,10 +77,8 @@ use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; -$legacyConsolePaths = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'; - -$oauthDefaultSuccess = $legacyConsolePaths ? '/console/auth/oauth2/success' : '/auth/oauth2/success'; -$oauthDefaultFailure = $legacyConsolePaths ? '/console/auth/oauth2/failure' : '/auth/oauth2/failure'; +$oauthDefaultSuccess = '/auth/oauth2/success'; +$oauthDefaultFailure = '/auth/oauth2/failure'; $createSession = function (string $userId, string $secret, Request $request, Response $response, User $user, Database $dbForProject, Document $project, array $platform, Locale $locale, Geo $geo, Event $queueForEvents, Bus $bus, Store $store, ProofsToken $proofForToken, ProofsCode $proofForCode, bool $domainVerification, ?string $cookieDomain, Authorization $authorization) { @@ -1378,11 +1376,9 @@ Http::get('/v1/account/sessions/oauth2/:provider') throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED); } - $host = $platform['consoleHostname'] ?? ''; - $redirectBase = $protocol . '://' . $host; - if ($protocol === 'https' && $port !== '443') { - $redirectBase .= ':' . $port; - } elseif ($protocol === 'http' && $port !== '80') { + $redirectBase = $platform['consoleUrl'] ?? ''; + // Only the derived console URL follows the request port; an explicit one carries its own + if (empty(System::getEnv('_APP_CONSOLE_URL')) && $port !== ($protocol === 'https' ? '443' : '80')) { $redirectBase .= ':' . $port; } @@ -2285,13 +2281,11 @@ Http::get('/v1/account/tokens/oauth2/:provider') throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED); } - $host = $platform['consoleHostname'] ?? ''; $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $port = $request->getPort(); - $redirectBase = $protocol . '://' . $host; - if ($protocol === 'https' && $port !== '443') { - $redirectBase .= ':' . $port; - } elseif ($protocol === 'http' && $port !== '80') { + $redirectBase = $platform['consoleUrl'] ?? ''; + // Only the derived console URL follows the request port; an explicit one carries its own + if (empty(System::getEnv('_APP_CONSOLE_URL')) && $port !== ($protocol === 'https' ? '443' : '80')) { $redirectBase .= ':' . $port; } @@ -2358,7 +2352,7 @@ Http::post('/v1/account/tokens/magic-url') ->inject('proofForPassword') ->inject('platform') ->inject('authorization') - ->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, MailPublisher $publisherForMails, array $plan, ProofsPassword $proofForPassword, array $platform, Authorization $authorization) use ($legacyConsolePaths) { + ->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, MailPublisher $publisherForMails, array $plan, ProofsPassword $proofForPassword, array $platform, Authorization $authorization) { if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } @@ -2496,17 +2490,13 @@ Http::post('/v1/account/tokens/magic-url') if (empty($url)) { $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; - $host = $platform['consoleHostname'] ?? ''; $port = $request->getPort(); - $callbackBase = $protocol . '://' . $host; - if ($protocol === 'https' && $port !== '443') { - $callbackBase .= ':' . $port; - } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase = $platform['consoleUrl'] ?? ''; + // Only the derived console URL follows the request port; an explicit one carries its own + if (empty(System::getEnv('_APP_CONSOLE_URL')) && $port !== ($protocol === 'https' ? '443' : '80')) { $callbackBase .= ':' . $port; } - $url = $legacyConsolePaths - ? "{$callbackBase}/console/auth/magic-url" - : "{$callbackBase}/auth/magic-url"; + $url = "{$callbackBase}/auth/magic-url"; } $url = Template::parseURL($url); diff --git a/app/controllers/general.php b/app/controllers/general.php index b8580aa742..7d7b6204f2 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -98,8 +98,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S } $errorView = __DIR__ . '/../views/general/error.phtml'; - $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; - $url = $protocol . '://' . $platform['consoleHostname']; + $url = $platform['consoleUrl'] ?? ''; $platformHostnames = $platform['hostnames'] ?? []; if ($rule->isEmpty()) { @@ -126,7 +125,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S if (\str_ends_with($host, $denyDomain)) { $exception = new AppwriteException(AppwriteException::RULE_NOT_FOUND, 'This domain is not connected to any Appwrite resources. Visit domains tab under function/site settings to configure it.', view: $errorView); - $exception->addCTA('Start with this domain', System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' ? "{$url}/console" : $url); + $exception->addCTA('Start with this domain', $url); throw $exception; } } @@ -205,11 +204,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S $resourceId = $rule->getAttribute('deploymentResourceId', ''); $type = ($resourceType === 'site') ? 'sites' : 'functions'; $exception = new AppwriteException(AppwriteException::DEPLOYMENT_NOT_FOUND, view: $errorView); - $region = $project->getAttribute('region', 'default'); - $ctaUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? "/console/project-{$region}-{$projectId}/{$type}/{$resourceType}-{$resourceId}" - : "/projects/{$projectId}/{$type}/{$resourceId}"; - $exception->addCTA('View deployments', $url . $ctaUrl); + $exception->addCTA('View deployments', $url . "/projects/{$projectId}/{$type}/{$resourceId}"); throw $exception; } @@ -294,11 +289,10 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S } if (!$authorized) { - $url = $protocol . "://" . $platform['consoleHostname']; $response ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Pragma', 'no-cache') - ->redirect($url . (System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' ? '/console/auth/preview?' : '/auth/preview?') + ->redirect($url . '/auth/preview?' . \http_build_query([ 'projectId' => $projectId, 'origin' => $protocol . '://' . $host, @@ -355,17 +349,11 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S $allowAnyStatus = !\is_null($apiKey) && $apiKey->isDeploymentStatusIgnored(); if (!$allowAnyStatus && $deployment->getAttribute('status') !== 'ready') { $status = $deployment->getAttribute('status'); - $region = $project->getAttribute('region', 'default'); - $legacyConsolePaths = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'; $collection = $type === 'function' ? 'functions' : 'sites'; - $resourceUrl = $legacyConsolePaths - ? "/console/project-{$region}-{$project->getId()}/{$collection}/{$type}-{$resource->getId()}" - : "/projects/{$project->getId()}/{$collection}/{$resource->getId()}"; + $resourceUrl = "/projects/{$project->getId()}/{$collection}/{$resource->getId()}"; // Function deployments are listed on the function page itself $deploymentsUrl = $type === 'function' ? $resourceUrl : "{$resourceUrl}/deployments"; - $deploymentUrl = $legacyConsolePaths - ? "{$deploymentsUrl}/deployment-{$deployment->getId()}" - : "{$resourceUrl}/deployments/{$deployment->getId()}"; + $deploymentUrl = "{$resourceUrl}/deployments/{$deployment->getId()}"; switch ($status) { case 'failed': @@ -389,11 +377,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S $permissions = $resource->getAttribute('execute'); if (!(\in_array('any', $permissions)) && !(\in_array('guests', $permissions))) { $exception = new AppwriteException(AppwriteException::FUNCTION_EXECUTE_PERMISSION_MISSING, view: $errorView); - $region = $project->getAttribute('region', 'default'); - $ctaUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? "/console/project-{$region}-{$project->getId()}/functions/function-{$resource->getId()}/settings" - : "/projects/{$project->getId()}/functions/{$resource->getId()}/settings"; - $exception->addCTA('View settings', $url . $ctaUrl); + $exception->addCTA('View settings', $url . "/projects/{$project->getId()}/functions/{$resource->getId()}/settings"); throw $exception; } } diff --git a/docker-compose.yml b/docker-compose.yml index 95793ba74f..8c6d1e1bf5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -124,7 +124,7 @@ services: - _APP_NOTIFICATIONS_TRACKING_SECRET - _APP_DOMAIN - _APP_CONSOLE_DOMAIN - - _APP_CONSOLE_URL_SCHEME=root + - _APP_CONSOLE_URL - _APP_CONSOLE_TRUSTED_PROJECTS - _APP_DOMAIN_TARGET_CNAME - _APP_DOMAIN_TARGET_AAAA @@ -427,8 +427,8 @@ services: - _APP_LOGGING_FORMAT - _APP_QUEUE_NAME - _APP_DATABASE_SHARED_TABLES - - _APP_CONSOLE_URL_SCHEME=root - _APP_CONSOLE_DOMAIN + - _APP_CONSOLE_URL - _APP_CONSOLE_TRUSTED_PROJECTS - _APP_DOMAIN - _APP_DOMAIN_TARGET_CNAME @@ -634,7 +634,10 @@ services: - _APP_LOGGING_FORMAT - _APP_WEBHOOK_MAX_FAILED_ATTEMPTS - _APP_DATABASE_SHARED_TABLES - - _APP_CONSOLE_URL_SCHEME=root + - _APP_OPTIONS_FORCE_HTTPS + - _APP_DOMAIN + - _APP_CONSOLE_DOMAIN + - _APP_CONSOLE_URL appwrite-worker-deletes: profiles: - separate @@ -847,7 +850,7 @@ services: - _APP_OPTIONS_ROUTER_FORCE_HTTPS - _APP_DOMAIN - _APP_CONSOLE_DOMAIN - - _APP_CONSOLE_URL_SCHEME=root + - _APP_CONSOLE_URL - _APP_CONSOLE_TRUSTED_PROJECTS - _APP_STORAGE_DEVICE - _APP_STORAGE_S3_ACCESS_KEY @@ -942,6 +945,10 @@ services: - _APP_LOGGING_CONFIG - _APP_LOGGING_FORMAT - _APP_DATABASE_SHARED_TABLES + - _APP_OPTIONS_FORCE_HTTPS + - _APP_DOMAIN + - _APP_CONSOLE_DOMAIN + - _APP_CONSOLE_URL extra_hosts: - host.docker.internal:host-gateway diff --git a/src/Appwrite/Deployment/GitAction.php b/src/Appwrite/Deployment/GitAction.php index 0d5d4103d6..c668029e49 100644 --- a/src/Appwrite/Deployment/GitAction.php +++ b/src/Appwrite/Deployment/GitAction.php @@ -50,13 +50,8 @@ final class GitAction default => $status }; - $hostname = $platform['consoleHostname'] ?? ''; - $region = $project->getAttribute('region', 'default'); $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()}"; + $targetUrl = ($platform['consoleUrl'] ?? '') . "/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 d5ea712b6c..1f26df9b1b 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php @@ -164,11 +164,9 @@ trait Deployment Span::add("{$logBase}.authorized", $isAuthorized); $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; - $hostname = $platform['consoleHostname'] ?? ''; + $consoleUrl = $platform['consoleUrl'] ?? ''; - $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}"; + $authorizeUrl = $consoleUrl . "/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}"; $action = $isAuthorized ? ['type' => 'logs'] : ['type' => 'authorize', 'url' => $authorizeUrl]; @@ -557,7 +555,6 @@ trait Deployment if (!empty($providerCommitHash) && $resource->getAttribute('providerSilentMode', false) === false) { $resourceName = $resource->getAttribute('name'); $projectName = $project->getAttribute('name'); - $region = $project->getAttribute('region', 'default'); $name = "{$resourceName} ({$projectName})"; $message = 'Starting...'; @@ -569,9 +566,7 @@ trait Deployment } $owner = $vcs->getOwnerName($providerInstallationId, (int) $providerRepositoryId); - $providerTargetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId" - : $protocol . '://' . $hostname . "/projects/$projectId/$resourceCollection/$resourceId"; + $providerTargetUrl = $consoleUrl . "/projects/$projectId/$resourceCollection/$resourceId"; $vcs->updateCommitStatus($repositoryName, $providerCommitHash, $owner, 'pending', $message, $providerTargetUrl, $name); } diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 76667cc350..f4c58cac17 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -276,11 +276,10 @@ class Webhooks extends Action $projectId = $project->getId(); $projectInternalId = $project->getSequence(); - $region = $project->getAttribute('region', 'default'); - $webhookId = $webhook->getId(); $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'disabled' ? 'http' : 'https'; $consoleHostname = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', 'localhost')); + $consoleUrl = \rtrim(System::getEnv('_APP_CONSOLE_URL', $protocol . '://' . $consoleHostname), '/'); $subject = 'Webhook deliveries have been paused'; $preview = 'Webhook "' . $webhook->getAttribute('name') . '" has been paused after ' . $attempts . ' failed delivery attempts.'; @@ -320,10 +319,8 @@ class Webhooks extends Action $template->setParam('{{project}}', $project->getAttribute('name')); $template->setParam('{{url}}', $webhook->getAttribute('url')); $template->setParam('{{error}}', 'The server returned ' . $statusCode . ' status code'); - $template->setParam('{{host}}', $protocol . '://' . $consoleHostname); - $template->setParam('{{path}}', System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? "/console/project-{$region}-{$projectId}/settings/webhooks/{$webhookId}" - : "/projects/{$projectId}/settings/webhooks"); + $template->setParam('{{host}}', $consoleUrl); + $template->setParam('{{path}}', "/projects/{$projectId}/settings/webhooks"); $template->setParam('{{attempts}}', $attempts); $publisherForNotifications->enqueue(new NotificationMessage( diff --git a/src/Appwrite/Vcs/Comment.php b/src/Appwrite/Vcs/Comment.php index 328dcaa19a..be36c92299 100644 --- a/src/Appwrite/Vcs/Comment.php +++ b/src/Appwrite/Vcs/Comment.php @@ -162,9 +162,7 @@ class Comment }; if ($site['action']['type'] === 'logs') { - $logsUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? "{$protocol}://{$hostname}/console/project-{$site['region']}-{$projectId}/sites/site-{$siteId}/deployments/deployment-{$site['deploymentId']}" - : "{$protocol}://{$hostname}/projects/{$projectId}/sites/{$siteId}/deployments/{$site['deploymentId']}"; + $logsUrl = ($this->platform['consoleUrl'] ?? '') . "/projects/{$projectId}/sites/{$siteId}/deployments/{$site['deploymentId']}"; $action = "[View Logs]({$logsUrl})"; } else { $action = '[Authorize](' . $site['action']['url'] . ')'; @@ -215,9 +213,7 @@ class Comment }; if ($function['action']['type'] === 'logs') { - $logsUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root' - ? "{$protocol}://{$hostname}/console/project-{$function['region']}-{$projectId}/functions/function-{$functionId}/deployment-{$function['deploymentId']}" - : "{$protocol}://{$hostname}/projects/{$projectId}/functions/{$functionId}/deployments/{$function['deploymentId']}"; + $logsUrl = ($this->platform['consoleUrl'] ?? '') . "/projects/{$projectId}/functions/{$functionId}/deployments/{$function['deploymentId']}"; $action = "[View Logs]({$logsUrl})"; } else { $action = '[Authorize](' . $function['action']['url'] . ')'; diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 4d8768470d..3d460b8c21 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -3440,7 +3440,7 @@ final class AccountCustomClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); - // Omit failure so Appwrite uses the default relay URL (/auth/oauth2/failure or legacy /console/...) + // Omit failure so Appwrite uses the default relay URL (/auth/oauth2/failure) $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'origin' => 'http://localhost', 'content-type' => 'application/json', @@ -3481,7 +3481,7 @@ final class AccountCustomClientTest extends Scope $query = []; \parse_str((string) \parse_url($location, PHP_URL_QUERY), $query); - $this->assertContains($path, ['/auth/oauth2/failure', '/console/auth/oauth2/failure']); + $this->assertEquals('/auth/oauth2/failure', $path); $this->assertEquals($projectId, $query['project'] ?? null); $this->assertNotEmpty($query['error'] ?? null); diff --git a/tests/unit/Platform/Workers/WebhooksTest.php b/tests/unit/Platform/Workers/WebhooksTest.php index e846531633..f514e5404f 100644 --- a/tests/unit/Platform/Workers/WebhooksTest.php +++ b/tests/unit/Platform/Workers/WebhooksTest.php @@ -31,7 +31,7 @@ final class WebhooksTest extends TestCase $publisherForNotifications = new NotificationPublisher($publisher, new Queue('v1-notifications')); $worker = new Webhooks(); - $this->withConsoleUrlScheme('legacy', fn () => $worker->sendAlert( + $worker->sendAlert( attempts: 10, statusCode: 500, webhook: new Document([ @@ -50,7 +50,7 @@ final class WebhooksTest extends TestCase dbForPlatform: $database, publisherForNotifications: $publisherForNotifications, plan: [] - )); + ); $events = $publisher->getEvents('v1-notifications'); @@ -68,7 +68,7 @@ final class WebhooksTest extends TestCase ); $this->assertStringContainsString('Payments', (string) $payload['body']); $this->assertStringContainsString('Ada Lovelace', (string) $payload['body']); - $this->assertStringContainsString('/console/project-fra-project-1/settings/webhooks/webhook-1', (string) $payload['body']); + $this->assertStringContainsString('/projects/project-1/settings/webhooks', (string) $payload['body']); $this->assertStringNotContainsString('{{', (string) $payload['body']); $this->assertSame(APP_NAME, $payload['variables']['platform']); $this->assertSame(APP_EMAIL_LOGO_URL, $payload['variables']['logoUrl']); @@ -95,43 +95,6 @@ final class WebhooksTest extends TestCase ], $payload['recipients'][1]); } - public function testSendAlertUsesRootConsolePathsWhenConfigured(): void - { - $database = $this->createPlatformDatabase(); - $this->seedOwnerUser($database); - - $publisher = new MockPublisher(); - $publisherForNotifications = new NotificationPublisher($publisher, new Queue('v1-notifications')); - $worker = new Webhooks(); - - $this->withConsoleUrlScheme('root', fn () => $worker->sendAlert( - attempts: 10, - statusCode: 500, - webhook: new Document([ - '$id' => 'webhook-1', - '$updatedAt' => '2026-01-01T00:00:00.000+00:00', - 'name' => 'Payments', - 'url' => 'https://example.test/webhook', - ]), - project: new Document([ - '$id' => 'project-1', - '$sequence' => 'project-internal-1', - 'name' => 'Production', - 'teamInternalId' => 'team-internal-1', - 'region' => 'fra', - ]), - dbForPlatform: $database, - publisherForNotifications: $publisherForNotifications, - plan: [] - )); - - $events = $publisher->getEvents('v1-notifications'); - - $this->assertCount(1, $events); - $this->assertStringContainsString('/projects/project-1/settings/webhooks', (string) $events[0]['body']); - $this->assertStringNotContainsString('/console/', (string) $events[0]['body']); - } - public function testSendAlertPersonalizesBodyPerOwner(): void { $database = $this->createPlatformDatabase(); @@ -234,18 +197,6 @@ final class WebhooksTest extends TestCase $this->assertSame('webhook:webhook-1:paused:2026-01-02T00:00:00.000+00:00', $events[1]['deduplicationKey']); } - private function withConsoleUrlScheme(string $scheme, callable $callback): void - { - $original = \getenv('_APP_CONSOLE_URL_SCHEME'); - \putenv("_APP_CONSOLE_URL_SCHEME={$scheme}"); - - try { - $callback(); - } finally { - \putenv($original === false ? '_APP_CONSOLE_URL_SCHEME' : "_APP_CONSOLE_URL_SCHEME={$original}"); - } - } - private function createPlatformDatabase(): Database { $authorization = new Authorization();