1
0
Fork 0
mirror of synced 2024-10-01 17:58:02 +13:00

Fix incorrect general_protocol_unsupported error

$requestHeaders was being referenced before it was set. This PR reverts
code back to using $swooleRequest to extract the header.
This commit is contained in:
Steven Nguyen 2023-10-31 18:31:36 +00:00 committed by GitHub
parent c4e22b1085
commit 7c8a9ad4d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -408,7 +408,7 @@ App::init()
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
*/
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if ($request->getProtocol() !== 'https' && ($requestHeaders['host'] ?? '') !== 'localhost' && ($requestHeaders['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations
if ($request->getProtocol() !== 'https' && ($swooleRequest->header['host'] ?? '') !== 'localhost' && ($swooleRequest->header['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations
if ($request->getMethod() !== Request::METHOD_GET) {
throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP. Please use HTTPS instead.');
}