diff --git a/app/controllers/general.php b/app/controllers/general.php index c63dfae1ab..1240d659a0 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -60,7 +60,9 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); var_dump($host); var_dump(APP_HOSTNAME_INTERNAL); - + var_dump($request->getHeader('host')); + var_dump($request->getHeader('x-forwarded-host')); + if ($route === null) { if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.'); diff --git a/src/Appwrite/Event/Build.php b/src/Appwrite/Event/Build.php index af517f2598..237803a7ff 100644 --- a/src/Appwrite/Event/Build.php +++ b/src/Appwrite/Event/Build.php @@ -115,7 +115,7 @@ class Build extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'resource' => $this->resource, 'deployment' => $this->deployment, diff --git a/src/Appwrite/Event/Certificate.php b/src/Appwrite/Event/Certificate.php index cacfcc867f..188e6dd27d 100644 --- a/src/Appwrite/Event/Certificate.php +++ b/src/Appwrite/Event/Certificate.php @@ -77,7 +77,7 @@ class Certificate extends Event $client = new Client($this->queue, $this->connection); return $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'domain' => $this->domain, 'skipRenewCheck' => $this->skipRenewCheck diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 69c38e2ec5..4b53b71d99 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -109,7 +109,6 @@ class Database extends Event public function trigger(): string|bool { - try { $dsn = new DSN($this->getProject()->getAttribute('database')); } catch (\InvalidArgumentException) { @@ -123,7 +122,7 @@ class Database extends Event try { $result = $client->enqueue([ - 'sourceRegion' => System::getEnv('_APP_REGION', 'default'), + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'type' => $this->type, diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 69cf8ddc2a..3595be9216 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -110,6 +110,8 @@ class Event return $this->event; } + + public function getSourceRegion(): string { return System::getEnv('_APP_REGION', 'default'); diff --git a/src/Appwrite/Event/Func.php b/src/Appwrite/Event/Func.php index 451df2b6c1..a099f7152c 100644 --- a/src/Appwrite/Event/Func.php +++ b/src/Appwrite/Event/Func.php @@ -220,6 +220,7 @@ class Func extends Event $events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null; return $client->enqueue([ + 'sourceRegion' => $this->getSourceRegion(), 'project' => $this->project, 'user' => $this->user, 'function' => $this->function, diff --git a/src/Appwrite/Event/Migration.php b/src/Appwrite/Event/Migration.php index 23b959c880..eddce6354e 100644 --- a/src/Appwrite/Event/Migration.php +++ b/src/Appwrite/Event/Migration.php @@ -80,7 +80,6 @@ class Migration extends Event return $client->enqueue([ 'sourceRegion' => $this->getSourceRegion(), - 'project' => $this->project, 'user' => $this->user, 'migration' => $this->migration diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 18d4f9bd79..36fe1a6d1a 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -90,8 +90,8 @@ class Builds extends Action $resource = new Document($payload['resource'] ?? []); $deployment = new Document($payload['deployment'] ?? []); $template = new Document($payload['template'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1d95fc6a51..7a4ce1ef0b 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -80,8 +80,8 @@ class Certificates extends Action $document = new Document($payload['domain'] ?? []); $domain = new Domain($document->getAttribute('domain', '')); $skipRenewCheck = $payload['skipRenewCheck'] ?? false; - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('domain', $domain->get()); $this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log,$realtimeConnection, $skipRenewCheck); } diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 5932deb7d9..7f3132dcb0 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -73,8 +73,8 @@ class Databases extends Action $collection = new Document($payload['collection'] ?? []); $document = new Document($payload['document'] ?? []); $database = new Document($payload['database'] ?? []); - $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; + $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 481486e63f..e03a8ac069 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -101,7 +101,6 @@ class Functions extends Action $this->sourceRegion = $payload['sourceRegion'] ?? 'default'; - if ($function->isEmpty() && !empty($functionId)) { $function = $dbForProject->getDocument('functions', $functionId); }