Added gobal API cors hostname config
This commit is contained in:
@@ -43,6 +43,13 @@ class mfBaseApicontroller {
|
||||
|
||||
register_shutdown_function(["mfBaseApicontroller", "return_errors"]);
|
||||
|
||||
// allow origins from config file
|
||||
if(defined("API_CORS_ALLOWED_HOSTNAMES") && is_array(API_CORS_ALLOWED_HOSTNAMES)) {
|
||||
foreach(API_CORS_ALLOWED_HOSTNAMES as $origin) {
|
||||
$this->addAllowedOrigin($origin);
|
||||
}
|
||||
}
|
||||
|
||||
// CORS preflight
|
||||
// allow all origins
|
||||
if($this->http_method == "OPTIONS") {
|
||||
@@ -71,7 +78,7 @@ class mfBaseApicontroller {
|
||||
if($this->requireAuth) {
|
||||
$this->authenticateUser();
|
||||
if(method_exists($this,"authenticated")) {
|
||||
$this->authenticated();
|
||||
$this->authenticated(); // event defined in extending class
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user