diff --git a/htdocs/api/index.php b/htdocs/api/index.php index da194f12655..ae84e61ea32 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -61,6 +61,13 @@ if (preg_match('/\/explorer\/swagger\.json/', $_SERVER["PHP_SELF"])) { header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY'); } +// When we request url to get an API, we accept Cross site so we can make js API call inside another website +if (preg_match('/\/api\/index\.php/', $_SERVER["PHP_SELF"])) { + header('Access-Control-Allow-Origin: *'); + header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); + header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY'); +} + $res = 0; if (!$res && file_exists("../main.inc.php")) {