From 268e60118c8bf455fe5926137acf66852d74cb90 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 29 Jan 2020 12:46:28 +0200 Subject: [PATCH] Allow empty origin for non-web platform --- app/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.php b/app/app.php index 9eb799f279..d12b62cab0 100644 --- a/app/app.php +++ b/app/app.php @@ -86,7 +86,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ $hostValidator = new Host($clients); $origin = $request->getServer('HTTP_ORIGIN', $request->getServer('HTTP_REFERER', '')); - if (!$hostValidator->isValid($origin) + if (!empty($origin) && !$hostValidator->isValid($origin) && in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE]) && empty($request->getHeader('X-Appwrite-Key', ''))) { throw new Exception('Access from this client host is forbidden. '.$hostValidator->getDescription(), 403);