无法获取 /parse/functions/

无法获取 /parse/functions/

我对维护 Parse 还很陌生,但我已经快要疯了 ;)

我们在 Debian 机器上设置了一个解析服务器。它运行 nginx 并使用 pm2 来部署 Parse。Parse-Dashboard 运行良好,甚至我们的解析服务器也弹出了它的 mongodb。但是,该服务器似乎无法正常工作。我们可以访问domain.com/parse/serverinfodomain.com/parse/users显示正确的用户列表。但是,从我们的云代码调用任何函数都是不可能的……它不起作用。

我反复在 Google 上搜索这个问题,似乎最多只能找到人们错误配置mount参数的情况index.js。然而,我们的情况并非如此。

这是我们的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);

Nginx 配置是:

# 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;
        }
}

我不知道我们的配置哪里出了问题,以及为什么会出现这种情况parse/usersparse/serverinfo 工作

答案1

解析服务器不处理得到。相反/functions,您可以通过以下方式调用云代码文件中预定义的所有云函数邮政反对/functions/your_function_name。您可以找到有关云代码的更多详细信息这里

大多数 SDK 都提供了与云代码交互的机制,可以为您处理此问题。根据您使用的 sdk(或直接使用 REST),您可以查看文档更多细节。

相关内容