通过解析服务器云代码推送:未找到网址

时间:2016-05-02 09:27:37

标签: parse-platform push-notification cloud-code parse-server

在Parse工作了很长时间后,我最近开始将数据移动到本地Parse服务器并编写示例应用程序以熟悉系统。到目前为止,我成功地完成了大部分工作,包括推使用het Parse Dashboard。

不幸的是,我似乎无法使用云代码来解析Parse Push。

这是我的代码:

Parse.Cloud.define('push', function(req, res) {
    var logMessage = "Push test";
    console.log(logMessage);
    var pushQuery = new Parse.Query(Parse.Installation);


    Parse.Push.send({
        where: pushQuery,
        data: {
        alert: 'Test'
    }
    }, {
        useMasterKey: true,
        success: function() {
        // Push sent, send re
        res.success('Push Sent');
        var logMessage = "Push Sent!";
        console.log(logMessage);

    },
    error: function(error) {
        res.error(error)


        var logMessage = error;
        console.log(logMessage);
        // There was a problem :(
    }
    });


    var logMessage = "Push should be sent.";
    console.log(logMessage);

});

很遗憾没有发送推送,并返回以下错误消息:

  {
  code: 107,
  message: 'Received an error with invalid JSON from Parse: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /push was not found on this server.</p>\n<hr>\n<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>\n</body></html>\n' }

它似乎表明推送请求被发送到主服务器的/ push目录,但我不知道如何将其更改为适当的位置,我认为解析服务器会自动选择正确的路径。< / p>

我希望有人可能知道如何解决这个问题,因为我现在没有想法......

1 个答案:

答案 0 :(得分:0)

对于所有处理同一问题的人来说,这是解决方案。

感谢Anbarasi的正确答案。我的服务器设置不正确。将服务器URL更改为正确的设置(地址+端口)后,一切都开始工作了!