Access-Control-Allow-Origin related error when updating user
D
Dede Indrapurna
started a topic
about 7 years ago
Hi Kinvey, Recently I got this error when I try to update a user:
"XMLHttpRequest cannot load https://baas.kinvey.com/user/kid_Teuf-CPNMO/525650494179765b45000fc1. 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.
D
Dede Indrapurna
said
about 7 years ago
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:
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`.
D
Dede Indrapurna
said
about 7 years ago
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?
Thanks!
M
Mark
said
about 7 years ago
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.
Dede Indrapurna
"XMLHttpRequest cannot load https://baas.kinvey.com/user/kid_Teuf-CPNMO/525650494179765b45000fc1. 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?
Thanks!