100% untested, but try this:
return [
'endpoints' => [
'api/jobs.json' => function() {
HeaderHelper::setHeader([
'Access-Control-Allow-Origin' => 'http://example.com'
]);
return [
'elementType' => 'Entry',
'criteria' => ['section' => 'jobs'],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'jsonUrl' => UrlHelper::getUrl("jobs/{$entry->id}.json"),
];
},
];
},
'api/jobs/<entryId:\d+>.json' => function($entryId) {
HeaderHelper::setHeader([
'Access-Control-Allow-Origin' => 'http://example.com'
]);
return [
'elementType' => 'Entry',
'criteria' => ['id' => $entryId],
'first' => true,
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'entryId' => $entry->id,
'postDate' => $entry->postDate,
];
},
];
},
]
];