some fixes
This commit is contained in:
@@ -111,13 +111,15 @@ class Request {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($_SERVER['REQUEST_METHOD'], $this->allowedMethods)) {
|
||||
$this->lastError = 'This method is not allowed';
|
||||
header('HTTP 1.1 405 Method Not Allowed');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->externalCall) {
|
||||
|
||||
// check the request method
|
||||
if (!in_array($_SERVER['REQUEST_METHOD'], $this->allowedMethods)) {
|
||||
$this->lastError = 'This method is not allowed';
|
||||
header('HTTP 1.1 405 Method Not Allowed');
|
||||
return false;
|
||||
}
|
||||
|
||||
$apiKeyAuthorized = false;
|
||||
|
||||
// Logged in or api key authorized?
|
||||
|
||||
@@ -33,7 +33,7 @@ class Settings {
|
||||
}
|
||||
|
||||
public static function loadDefaults(): Settings {
|
||||
$hostname = $_SERVER["SERVER_NAME"];
|
||||
$hostname = $_SERVER["SERVER_NAME"] ?? "localhost";
|
||||
$protocol = getProtocol();
|
||||
$jwt = generateRandomString(32);
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@ spl_autoload_register(function($class) {
|
||||
|
||||
|
||||
function getProtocol(): string {
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
|
||||
$isSecure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
|
||||
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
|
||||
(!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on');
|
||||
|
||||
return $isSecure ? 'https' : 'http';
|
||||
}
|
||||
|
||||
function generateRandomString($length): string {
|
||||
|
||||
Reference in New Issue
Block a user