In a project we are using Restfullyii extension from evan108108 (http://www.yiiframework.com/extension/restfullyii). Everything works fine. But now we wanted to implement an own action to a controller. When working on localhost everything works fine. But we have a client - server setup from different domains.
This is our setup:
class Controller extends CController
{
public function restEvents()
{
$this->onRest('req.cors.access.control.allow.origin', function() {
return ['http://localhost', 'http://localhost:8888', 'http://local.yyyyyyy.dev', 'http://local.yyyyyyy.test', 'http://dev.xxxxxx.yyyyyy.ch', 'http://test.xxxxxx.yyyyyy.ch', 'http://xxxxxx.yyyyyy.ch', 'http://zzzzzzzz.ch']; //List of sites allowed to make CORS requests
});
$this->onRest('req.cors.access.control.allow.methods', function() {
return ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']; //List of allowed http methods (verbs)
});
// @TODO: not sure if ok to overwrite all headers
$this->onRest('req.cors.access.control.allow.headers', function() {
return ['Origin, X-Requested-With, Content-Type, Accept, Access-Control-Allow-Origin'];
});
$this->onRest('post.filter.req.auth.ajax.user', function($validation) {
return true; // HACK! Allow always, see https://github.com/evan108108/RESTFullYii#customization--configuration
});
}
}
InvoiceController with the own action, inheriting from Controller
class InvoiceController extends Controller
{
/**
* @return array action filters
*/
public function filters()
{
return array(
array(
'ext.starship.RestfullYii.filters.ERestFilter +
REST.GET, REST.PUT, REST.POST, REST.DELETE, REST.OPTIONS'
),
);
}
public function actions() {
return array(
'REST.' => 'ext.starship.RestfullYii.actions.ERestActionProvider',
);
}
/**
* configure custom routes/actions
*/
public function restEvents()
{
parent::restEvents();
$this->onRest('req.post.calculate.render', function($param1)
{
}
}
}
But then we get a CORS respectively a "CAUTION: Provisional headers are shown" (see attached file).
Does somebody know how to solve this?