You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cloud code function responds with error:undefined/unauthorized #546
I have performed a test migration of my Parse db and application to a self-hosted solution.
I have successfully authenticated my PFUser with parse-server with an iOS client.
NB :
I have successfully executed the hello example in main.js using curl to ensure that my parse server endpoint is correctly configured. I can also execute this from my iOS client code. So cloud-functions are working on the desired end-point.
However I am having problems in getting any of my cloud-code Query functions to execute properly.
Here is an example of a test function that has the problem.
I get this error when calling from inside an iOS app, after authenticating and ensuring that PFUser is valid, or just when calling with curl outside of an established session.
It is unclear to me why the code should be undefined or what is happening here.
Is this a defect or is there something wrong with my cloud code?
I have added the query.userMasterKey = true line having read that this was required in the migration docs. Adding or removing it seems to make no difference.
The problem was with the Parse-Server initialisation in index.js
The migration documents do not mention that its necessary to supply a value for 'serverURL' but unless you do then cloud-code calls won't work correctly.
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/test',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myApp',
masterKey: process.env.MASTER_KEY || 'myMaster', //Add your master key here. Keep it secret!
fileKey: 'myFiles',
javascriptKey: 'myJSKey',
clientKey:'myClientKey',
**serverURL: 'http://localhost:1337/parse'**
});
That goes wherever you initialise your Parse server. See the link in the README here [https://github.com/ParsePlatform/parse-server#parse-server--express]
Yes in your case app.js is most likely the correct location where express is configured. YMMV, things may have changed since February when I posted the comment
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var api = new ParseServer({
databaseURI: databaseUri || 'URi',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'id',
masterKey: process.env.MASTER_KEY || 'key', //Add your master key here. Keep it secret!
fileKey: 'key',
javascriptKey: '',
clientKey:'',
**serverURL: 'URL'**
});
// Serve the Parse API at /parse URL prefix
app.use('/parse', api);
var port = 1337;
app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
Activity
paulfreeman commentedon Feb 21, 2016
The problem was with the Parse-Server initialisation in index.js
The migration documents do not mention that its necessary to supply a value for 'serverURL' but unless you do then cloud-code calls won't work correctly.
Yoloabdo commentedon Jul 7, 2016
Hello @paulfreeman, where to add this var api? to main.js? or another file?
paulfreeman commentedon Jul 7, 2016
That goes wherever you initialise your Parse server. See the link in the README here [https://github.com/ParsePlatform/parse-server#parse-server--express]
Yoloabdo commentedon Jul 7, 2016
I've seen that but couldn't figure it out too, i'm using nodechef and that's the tree of files i've
i've tried to create app.js and insert into it but didn't work either, thanks a lot for the quick reply!
paulfreeman commentedon Jul 7, 2016
Yes in your case app.js is most likely the correct location where express is configured. YMMV, things may have changed since February when I posted the comment
Yoloabdo commentedon Jul 7, 2016
here's my code, can you give it a look
anything wrong?
rawatshailender commentedon Nov 3, 2016
Please check the version of parse-server being used. I had found similar issues with 2.2.12
flovilmart commentedon Nov 3, 2016
@Yoloabdo, you should contact nodechef support as they're not using the original parse-server