Hi,
I'm trying to build an Owncloud app and register External API calls in
order to allow third party applications to access data provided by
Owncloud.
I've added the following to the .htaccess file of Owncloud:
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Authorization, Content-Type"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE,
OPTIONS"
Header set Access-Control-Allow-Credentials "true"
In appinfo/routes.php:
\OCP\API::register('options', '/path', array('OCA\Owncloud_app',
'function#preflighted_cors'), 'owncloud_app', OC_API::USER_AUTH);
\OCP\API::register('post', '/path', array('OCA\Owncloud_app',
'function'), 'owncloud_app', OC_API::USER_AUTH);
The request from third party application is:
$.support.cors = true;
$.ajax({
beforeSend: function (xhr) {
var username = username;
var password = password;
var auth = btoa(username + ':' + password);
xhr.setRequestHeader('Authorization', 'Basic ' + auth);
},
url: url,
type: 'POST',
contentType: 'application/json',
success: function(data,status) {
},
error: function (request, status, error) {
}
});
The third party application is served at http://localhost:9000 and the
owncloud is served from http://localhost/owncloud. This is causing a
CORS issue. I've tried everything that I can think of, but I keep
getting an error saying the request was blocked and that the preflight
channel did not succeed.
When I change USER_AUTH to GUEST_AUTH everything is ok with no CORS
error.
Any ideas or solutions? Any help is appreciated.
Thanks,
Sotiris
_______________________________________________
User mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/user