header set

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-18 16:45:13 -04:00
parent 24aa32dedf
commit 3884bbf561
+18
View File
@@ -253,6 +253,24 @@ class WrenchApi extends BaseController
return $in;
}
public function apigate(){
if (array_key_exists('HTTP_ORIGIN', $_SERVER)) {
$origin = $_SERVER['HTTP_ORIGIN'];
} else if (array_key_exists('HTTP_REFERER', $_SERVER)) {
$origin = $_SERVER['HTTP_REFERER'];
} else {
$origin = $_SERVER['REMOTE_ADDR'];
}
$allowed_domains = array(
'http://localhost:9082/',
'https://users.wrenchboard.com/',
);
if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
/*
//$request = service('request');
header('Access-Control-Allow-Origin: *');