CORS, trusted domain

This commit is contained in:
2024-04-11 11:51:50 -04:00
parent a238ad3b7f
commit 3851b7f289
12 changed files with 80 additions and 14 deletions

View File

@@ -161,8 +161,20 @@ abstract class Request {
return true;
}
protected function getCORS(): array {
$settings = $this->context->getSettings();
return $settings->getTrustedDomains();
}
public final function execute($values = array()): bool {
if ($this->externalCall) {
$trustedDomains = $this->getCORS();
if (!empty($trustedDomains)) {
header("Access-Control-Allow-Origin: " . implode(", ", $trustedDomains));
}
}
$this->params = array_merge([], $this->defaultParams);
$this->success = false;
$this->result = array();