From 28b02a4ba863c6640b6f8379074181e693e5ad51 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 18 Oct 2024 21:18:20 +0000 Subject: [PATCH] chore: fix bug --- src/Appwrite/Platform/Workers/Certificates.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1f57daaa42..cec0706a79 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -160,7 +160,10 @@ class Certificates extends Action try { // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + $letsEncryptData = $this->issueCertificate($folder, $domain->get(), $email); + + // Give certificates to Traefik + $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); } catch (\Throwable $th) { Console::error('Failed to generate Lets Encrypt certificate'); } @@ -176,9 +179,6 @@ class Certificates extends Action Console::error('Failed to add custom hostname to registrar: ' . $th->getMessage()); } - // Give certificates to Traefik - $this->applyCertificateFiles($folder, $domain->get(), $letsEncryptData); - // Update certificate info stored in database $certificate->setAttribute('renewDate', $this->getRenewDate($domain->get())); $certificate->setAttribute('attempts', 0); @@ -222,13 +222,13 @@ class Certificates extends Action { $client = new Client(); $client - ->addHeader('Content-Type', Client::CONTENT_TYPE_APPLICATION_JSON) + ->addHeader('content-type', Client::CONTENT_TYPE_APPLICATION_JSON) ->addHeader('Authorization', 'Bearer ' . System::getEnv('_APP_SYSTEM_CLOUDFLARE_TOKEN')); $response = $client->fetch("https://api.cloudflare.com/client/v4/zones/b2d0e62383d3c0f6299efab107af2c7a/custom_hostnames", Client::METHOD_POST, [ 'custom_metadata' => [ - 'projectId' => $project->getId(), - 'organizationId' => $project->getAttribute('teamId') + 'projectId' => $project->getId() ?? '', + 'organizationId' => $project->getAttribute('teamId', '') ], 'hostname' => $hostname, 'ssl' => [