fixed cors check

This commit is contained in:
Frank Schubert
2022-12-01 14:28:31 +01:00
parent 2e1bf73281
commit 683364f70b

View File

@@ -50,6 +50,8 @@ class mfBaseApicontroller {
header("Access-Control-Allow-Methods: GET,POST,OPTIONS");
header("Access-Control-Allow-Headers: X-Api-Key");
$this->log->debug("origin header: ".$this->headers['origin']);
if(preg_match('#^(https?)://(.+)(:\d+)?$#i', $this->headers['origin'], $m)) {
$origin_proto = $m[1];
$origin_hostname = $m[2];
@@ -325,7 +327,7 @@ class mfBaseApicontroller {
$request_origin = ["proto" => false, "hostname" => ""];
$m = [];
if(preg_match('#^(https?)://(.+)(:\d+)?$#i', $this->headers['origin'], $m)) {
if(preg_match('#^(https?)://(.+)(:\d+)?/?$#i', $this->headers['origin'], $m)) {
$request_origin['proto'] = $m[1];
$request_origin['hostname'] = $m[2];
}
@@ -337,7 +339,7 @@ class mfBaseApicontroller {
$hostname = $origin;
$m = [];
if(preg_match('#^(https?)://(.+)$#i', $origin, $m)) {
if(preg_match('#^(https?)://(.+)/?$#i', $origin, $m)) {
$proto = $m[1];
$hostname = $m[2];
}