Update plugin.php
Added full CORS policy and OPTIONS method to allow API call from JavaScript
This commit is contained in:
parent
5abddff1aa
commit
f1639a2646
1 changed files with 9 additions and 1 deletions
|
@ -68,6 +68,14 @@ class pluginAPI extends Plugin {
|
||||||
// METHOD
|
// METHOD
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
$method = $this->getMethod();
|
$method = $this->getMethod();
|
||||||
|
|
||||||
|
// Added full CORS policy and OPTIONS method to allow API call from JS
|
||||||
|
if ($method === 'OPTIONS'){
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
header('Access-Control-Allow-Methods: GET, HEAD, OPTIONS, POST, PUT');
|
||||||
|
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// METHOD INPUTS
|
// METHOD INPUTS
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
@ -761,4 +769,4 @@ class pluginAPI extends Plugin {
|
||||||
'message'=>'Error moving the file to the final path.'
|
'message'=>'Error moving the file to the final path.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue