0

I am using google cloud & database on mLab for deployment of the parse server. i have taken a compute engine instance and a bitnami parse-stack over it , i have configured all variables in server.js file accordingly to example provided by parse in github . Every api works fine like JAVASCRIPT , i am able make calls from javascript files and get data from database. But the issue is with RESTAPI, my parse server is not able to recognize rest api key.

This is the CURL from my API CONSOLE from dash board

  curl -X POST \ -H "X-Parse-Application-Id: {my app id}" \ -H "X-Parse-REST-API-Key: undefined" \ http://serverURL/parse/functions/Show

this my server.js file during parse initialization

const parseServer = new ParseServer({ databaseURI: nconf.get('DATABASE_URI') || cloud: nconf.get('CLOUD_PATH') || appId: nconf.get('APP_ID'), masterKey: nconf.get('MASTER_KEY'),

serverURL: nconf.get('SERVER_URL'), restAPIKey: nconf.get('REST_API_KEY'),
javascriptKey: nconf.get('JAVASCRIPT_KEY'),
clientKey: nconf.get('CLIENT_KEY'),
dotNetKey: nconf.get('.NET_KEY'),

}

As you could see the RESTAPI key is being undefined in the curl. i couldn't understand where was i making a mistake. Please provide me with some advice . Thanks in adavance.

1 Answer 1

2

bitnami developer here.

I have followed your instructions and I'm not able to reproduce your issue.

I've created a machine in google cloud with the bitnami parse instance on the top of it. Then, I went to the url of the application and I created a class called GameScore.See this screenshot.

Then, I've followed the github parse example in order to make a curl to introduce data in the database. This is the curl I made, which it worked for me.

curl -X POST \
  -H "X-Parse-Application-Id: APPID_FORM_SERVER.JS" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:1337/parse/classes/GameScore

The APPID_FROM_SERVER.JS is the one I get from the server.js file. Then in the dashboard I'm able to see what I've send to the server.

My server.js file is the default one, which is in /opt/bitnami/apps/parse/htdocs/server.js

It seems that the configuration of your server.js is wrong. This is how a default server.js file looks like:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
    databaseURI: "mongodb://root:[email protected]:27017/bitnami_parse",
    cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
    appId: "d774b123a533e0ba2169b4926ed99de5676d59ef",
    masterKey: "5cdbe7c6fdb090c97cbf794a701dd697a70716ab",
    fileKey: "80e8cf19d1467992c6559a5826fef0278d489f9a",
    serverURL: 'http://35.187.2.104:80/parse'
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var port = 1337;
app.listen(port, function() {
    console.log('parse-server running on port ' + port);
});

//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
    apps: [
        {
            appName: "My Bitnami Parse API",
            appId: "d774b123a533e0ba2169b4926ed99de5676d59ef",
            masterKey: "5cdbe7c6fdb090c97cbf794a701dd697a70716ab",
            fileKey: "80e8cf19d1467992c6559a5826fef0278d489f9a",
            production: true,
            serverURL: 'http://35.187.2.104:80/parse'
        }
    ]
});

var allowInsecureHTTP = true;

// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);

var portdash = 4040;
app.listen(portdash, function() {
    console.log('parse-dashboard running on port ' + portdash);
});

You must log in to answer this question.