Start a new topic

Access-Control-Allow-Origin related error when updating user

Hi Kinvey, Recently I got this error when I try to update a user:

"XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access."

However, when I check it in the database, the user was actually updated successfully, but the $.ajax method returns "error" and thus, I cannot proceed to the next step since it was reported as an error.

Is there anyone having the same problem as mine and have a solution?


Which library are you using, or are you manually building the request? If so, please share your code.
I use REST API and manually building the request using jQuery. What's weird is that a week ago it works perfectly but now it's not. I don't remember changing anything with the code though..

Frameworks that I used: I use Kendo UI, MachinaJS FSM, jQuery, and Facebook javascript SDK.

Here's the function of the code that causes the error:

var data = {

"_socialIdentity": {

"facebook": {

"access_token": result.facebook.userToken,




"gender": result.gender,

"birthday": result.birthday,

"location": result.location,

"username": result.username,

"locale": result.locale,

"photoURL": result.photoURL



"username": result.username


var headers = {

"Authorization": "Kinvey " + result.sessionToken,

"X-Kinvey-Api-Version": params.apiVersion



url: params.apiUrl + "/user/" + params.apiKey + "/" + result.objectId,

type: "put",

dataType: "json",

headers: headers,

data: data,

success: function(response, status, xml){

if(xml.status == 200){


app.writeLog("Login success");

//Save the user details in the local storage

localStorage.user = JSON.stringify(result);

//Send the result back to Unity"LoginComplete", localStorage.user);



app.writeLog(xml.status, "error");




error: function(xml, status, ex){

app.writeLog(xml.status, "error");



Thanks for the info. Turns out this is an issue on our side when returning integers from a collection hook. For now, you can fix this by updating your Collection Hooks on the user collection. Just change the lines `response.body = docs` into `response.body = "" + docs`.
Hi Mark,

I've tried that but it doesn't work. I tried with another table which I don't have any custom code in the collection hook, but still that error appears. It seems that it only affects 'PUT' method. Do you have any other solution?

What collection are you targeting? In the logs, there are still a few requests from this morning which are caused by the issue I described in my previous post.
Login or Signup to post a comment