Skip to content

Commit

Permalink
Merge pull request #5188 from singhbhaskar/feat-5159-improve-error-wh…
Browse files Browse the repository at this point in the history
…en-creating-custom-domain

Updated the error to 501 error code for custom domain when _APP_DOMAIN and _APP_DOMAIN_TARGET is setup incorrectly
  • Loading branch information
christyjacob4 committed Mar 22, 2023
2 parents 5f1fb5a + 5c2c968 commit 6122a25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/config/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,11 @@
'description' => 'Domain verification for the requested domain has failed.',
'code' => 401,
],
Exception::DOMAIN_TARGET_INVALID => [
'name' => Exception::DOMAIN_TARGET_INVALID,
'description' => 'Your Appwrite instance is not publicly accessible. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.',
'code' => 501,
],
Exception::GRAPHQL_NO_QUERY => [
'name' => Exception::GRAPHQL_NO_QUERY,
'description' => 'Param "query" is not optional.',
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));

if (!$target->isKnown() || $target->isTest()) {
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.');
throw new Exception(Exception::DOMAIN_TARGET_INVALID, 'Unreachable CNAME target (' . $target->get() . '). Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
}

$domain = new Domain($domain);
Expand Down
1 change: 1 addition & 0 deletions src/Appwrite/Extend/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Exception extends \Exception
public const DOMAIN_NOT_FOUND = 'domain_not_found';
public const DOMAIN_ALREADY_EXISTS = 'domain_already_exists';
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
public const DOMAIN_TARGET_INVALID = 'domain_target_invalid';

/** GraphqQL */
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
Expand Down

0 comments on commit 6122a25

Please sign in to comment.