Fixed cors headers

This commit is contained in:
Frank Schubert
2022-11-08 19:27:14 +01:00
parent ade53322f1
commit 4323e8e683
@@ -47,6 +47,9 @@ class mfBaseApicontroller {
// allow all origins // allow all origins
if($this->http_method == "OPTIONS") { if($this->http_method == "OPTIONS") {
// dont execute route, OPTIONS only requires CORS headers // dont execute route, OPTIONS only requires CORS headers
header("Access-Control-Allow-Methods: GET,POST,OPTIONS");
header("Access-Control-Allow-Headers: X-Api-Key");
if(preg_match('#^(https?)://(.+)(:\d+)?$#i', $this->headers['origin'], $m)) { if(preg_match('#^(https?)://(.+)(:\d+)?$#i', $this->headers['origin'], $m)) {
$origin_proto = $m[1]; $origin_proto = $m[1];
$origin_hostname = $m[2]; $origin_hostname = $m[2];