I am quite new to maintaining Parse, but already I am about to go insane ;)

We have a parse server setup on a debian machine. It runs nginx and uses pm2 for the deployment of Parse. Parse-Dashboard is working well, even our parse server is popping up there with its mongodb. However, the server doesn't seem to work for us. We can access domain.com/parse/serverinfo and e.g. domain.com/parse/users, which will show us the correct user list. However, calling any of our functions from our cloud code is out of the question... it doesn't work.

I have been googling and googling this issue over and over, and the most I can seem to find is people having the mount parameter in their index.js incorrectly configured. However, that is not the case for us.

This is our index.js:

// Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var S3Adapter = require('parse-server').S3Adapter;

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
    console.log('DATABASE_URI not specified, falling back to localhost.');
}

var protocol = process.env.HTTPS ? 'https://' : 'http://';
var port = process.env.PORT || 1337;

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

var api = new ParseServer({
    databaseURI: databaseUri || 'mongodb://****:****@api.domain.com:27017/parse' || 'mo$
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
    appId: process.env.APP_ID || '*****',
    masterKey: process.env.MASTER_KEY || '*****', //Add your master$
    fileKey: process.env.FILE_KEY || '*****',
    serverURL: 'http://api.domain.com:' + port + '/parse' || process.env.SERVER_URL || protocol + $
    liveQuery: {
        classNames: ["Posts", "Comments"]
    },
    publicServerURL: 'http://api.domain.com:' + port + '/parse',
    filesAdapter: new S3Adapter(
        "*****",
        "/*****/*****",
        "*****", {
            directAccess: true
        }
    )
});

var app = express();
var publicServerURL = "http://api.domain.com:1337/parse";

app.use('/public', express.static(path.join(__dirname, '/public')));

console.log("Mounth path: " + process.env.PARSE_MOUNT);

var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

app.get('/', function(req, res) {
    res.status(200).send('I dream of being a website.  Please star the parse-server repo on GitHub!');
});

app.get('/test', function(req, res) {
    res.sendFile(path.join(__dirname, '/public/test.html'));
});

console.log('serverUrl configured as', protocol + 'localhost:' + port + '/parse');

var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

ParseServer.createLiveQueryServer(httpServer);

The Nginx config is:

# HTTP - redirect all requests to HTTPS
server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;
}

# HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server
server {
        listen 443;
        server_name api.domain.com;

        root /usr/share/nginx/html;
        index index.html index.htm;

        ssl on;
        ssl_certificate /etc/nginx/certificates/api.domain.com.crt;
        ssl_certificate_key /etc/nginx/certificates/api.domain.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

        # Pass requests for /parse/ to Parse Server instance at localhost:1337
        location /parse/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://localhost:1337/parse/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_redirect off;
        }
        location / {
                try_files $uri $uri/ =404;
        }

        location /dashboard/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://00.000.00.000:4040/dashboard/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_redirect off;
        }
}

I cannot figure out what it is that we have incorrect in our config, and why parse/users and parse/serverinfo does work

parse-server does not handle GET for /functions. Instead you can call all your cloud functions pre-defined in your cloud code file via POST against /functions/your_function_name. You can find more details about cloud code here .

Most of the SDKs provide a mechanism to interact with cloud code that handles this for you. Depending on which sdk you're using (or REST directly) you can check out the docs for more details.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.