Topic by Iain McKay
I'm trying to investigate and implement both a REST service (and hitting problems even when using 3rd party libraries such as "codeigniter-restserver" due to the differences in the RightNow CodeIgniter customisations) and separately to perform cross-site scripting with CORS rather than JSONP (which I've got working perfectly well at present).
So putting aside the REST issues, I'm looking for tips on how to implement CORS in a Custom Controller. i.e.something like:
$this->output->set_header("Access-Control-Allow-Origin: *");
$this->output->set_header('Access-Control-Allow-Credentials: true');
$this->output->set_header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
$this->output->set_header("Access-Control-Allow-Headers: X-API-KEY");
}
Any tips are very much appreciated.
Regards,
Iain.