-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Unable to connect to the Parse API" error thrown when trying to call a Cloud function with a Parse Query. #651
Comments
Can you provide more context and detailed steps to reproduce the issue? That way it is easier to track down the root cause and it will be easier to provide help and a fix if necessary. |
@grassland-curing-cfa did you set the serverURL in your parse server configuration? |
@flovilmart No, I didn't. Where is the parse server configuration where the serverURL is set, in index.js? I have the following index.js in my Parse-Server-Example folder.
|
Provide a serverURL option to the ParseServer call, something like: var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
restAPIKey: process.env.REST_API_KEY || '',
javascriptKey: process.env.JAVASCRIPT_KEY || '',
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
masterKey: process.env.MASTER_KEY || '' //Add your master key here. Keep it secret!
}); |
@gfosco Do I also need to set a Config Variable "SERVER_URL" in Heroku's Settings page? If so, and how? I thought "PARSE_MOUNT" would do that... ...
|
Yes for heroku that would be your full heroku app address, like |
This helped! |
Since the problem fixed by adding SERVER_URL, I am still curious about why this was needed as it seems "PARSE_MOUNT: /parse" does the same thing. I have another Parse-server-exemple app deployed on Heroku but that one worked well without SERVER_URL set. Very weird. |
The server url was added at some point, and was necessary for cloud code to know the right server to connect to when making requests back to the API. The mount variable is necessary for other reasons, just to know where on the domain it is hosted (creating file urls for example). |
@gfosco I came across same issue, however, even after adding serverURL I am getting "XMLHttpRequest failed: "Unable to connect to the Parse API"". my parse-server is running on localhost.
Mongodb is hosted on MongoLab. |
I am using self hosted parse-server and not able to use cloud functions since I have enabled HTTPS, if I revert it back to HTTP it works as expected. Also he problem is only with those cloud function which have Parse.Query, if i create a function simply return "Hello" as response it works on both HTTP and HTTPS. I am getting following error message when run a cloud function which have Parse.Query code. { can anyone tell me how can I fix this? |
Please check also this issue. |
I am having the same issue. Parse Query inside Cloud Code runs well with HTTP, however fails with "Unable to connect to the Parse API" when using HTTPS. Any hints? |
Just found the solution here: Just added: in index.js, just before starting Parse Server:
|
I was having the same issue and initially i though it was the cloud code that needed update. After a lot of troubleshooting I realised that the code was fine. Then I tried to see whether parse server was setup correctly. I am running it on IBM BlueMix (should be the same as heroku). The problem was the following
The server url was resolving to "http0.0.0.0:61026/parse", which was incorrect. I updated it to include :// and the problem was resolved. The new configuration looked like the following:
Such a simple mistake took me 4 hours to resolve. |
my problem was i wasn't supply full cloud path |
I have defined a Cloud function in main.js as below:
While trying the POST cURL command line to call the function, the command line prompt showed the following error message:
curl -X POST -H "X-Parse-Application-Id: APP_ID" -H "X-Parse-Master-Key: MASTER_KEY" -H "Content-Type: application/json" -d "{}" https://{MY_APP_NAME}.herokuapp.com/parse/functions/getAllCurrentObs
{"code":141,"error":"Error: 100 XMLHttpRequest failed: \"Unable to connect to the Parse API\""}
The Heroku logs page showed:
2016-02-25T12:33:14.263956+00:00 heroku[router]: at=info method=POST path="/parse/functions/getAllCurrentObs" host={MY_APP_NAME}.herokuapp.com request_id=6af8cfa4-c935-4b52-a869-1d5dd47b93aa fwd="183.78.173.3" dyno=web.1 connect=0ms service=2764ms status=400 bytes=378
By the way, using cURL to post the default "hello" cloud function worked well.
Edit: I think the problem is any Parse Query made to a DB Class in a cloud function would fail.
The text was updated successfully, but these errors were encountered: