parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Cloud Code not working properly

Open petritz opened this issue 10 years ago • 8 comments

I have a cloud code running on my parse-server. Some requests just work fine and with no problems, but some requests return weird errors.

So I have a function which performs a query on the database and returns the result. And when I try to get the result the following error occurs: 107: Received an error with invalid JSON from Parse: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /classes/_User was not found on this server.</p>\n<hr>\n<address>Apache/2.4.10 (Debian) Server at localhost Port 80</address>\n</body></html>\n'

Another funny thing is that request.user.id seems to return a different objectId than the real one of the user.

I could not figure out a problem with my code, because it worked fine on parse.com.

petritz avatar Feb 22 '16 18:02 petritz

That error message is coming from an Apache server running on port 80. Are you making a connection to the wrong address or port?... Take a look and make sure your server configuration is correct, and please provide code and details around a specific issue you're having.

gfosco avatar Feb 22 '16 19:02 gfosco

As I said, the other functions work fine and return responses so I obviously have the right configuration.

result_query.find({ ... at this function the error occurs. (Normal query made with new Parse.Query("_User"))

The other error with request.user.id happens with following code:

Parse.Cloud.useMasterKey();
...
    var queryForVipStatus = new Parse.Query("UserBarInfo");
    queryForVipStatus.equalTo("user", {
        __type: "Pointer", className: "_User", objectId: request.user.id
    }).first({ ...

at this point the function first(... ) does not return a thing because the id is wrong.

petritz avatar Feb 22 '16 19:02 petritz

You must troubleshoot this. Why is an apache server handling this request instead of a parse-server?

gfosco avatar Feb 22 '16 20:02 gfosco

Did you set serverURL parameter correctly? by default it is set to api.parse.com/1

merowinger92 avatar Feb 22 '16 22:02 merowinger92

As this is cloud code, I don't think you have to set this value. But I tried doing so in the ParseServer({ ... }) initializer and on top of my main cloud code file Parse.serverURL = 'http://localhost:1337/parse'; But it still has the same error. And I don't understand why my apache server should be the problem here.

petritz avatar Feb 23 '16 05:02 petritz

Hi @applemarkus, did manage to get a solution to this problem? I'm experiencing the same thing.

jsmcgd avatar Mar 07 '16 12:03 jsmcgd

yeah, I had cloned the parse-example-server a while ago and at this time there was no serverURL parameter.

petritz avatar Mar 07 '16 15:03 petritz

Thanks @applemarkus, that worked :)

jsmcgd avatar Mar 08 '16 14:03 jsmcgd