简体   繁体   English

云代码的解析服务器问题。

[英]Parse-server problems with cloud code.

I've deployed a parse-server to heroku (mLab.com as database) but have some problems with cloud code.我已将解析服务器部署到 heroku(mLab.com 作为数据库),但在云代码方面存在一些问题。

When calling the "hello" function, everything works fins.调用“hello”函数时,一切正常。

When calling the "testFunction", which in turns makes a query request, I get this error:当调用“testFunction”时,它反过来发出查询请求,我收到此错误:

  XMLHttpRequest cannot load https://xxxxx.herokuapp.com/parse/functions/testFunction. 
    No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://127.0.0.1:51488' is therefore not allowed access. 
The response had HTTP status code 503.

Been playing around with cors without any luck.一直在玩 cors 没有任何运气。 Any suggestions would be very appreciated.任何建议将不胜感激。

------------ CLIENT ------------
Parse.initialize("xxxxxx");
Parse.serverURL = 'https://xxxxx.herokuapp.com/parse/'

Parse.Cloud.run('hello').then(function (result) {
    console.log(result);
});

Parse.Cloud.run('testFunction').then(function (result) {
    console.log(result);
});

------------ SERVER -----------  

Parse.Cloud.define('hello', function (req, res) {
    res.success('Hi');
});

Parse.Cloud.define("testFunction", function (request, response) {
    var query = new Parse.Query("Jobs");
    query.find().then(function (result) {
        response.success("Success: " + result);
    });
});

Find out the problem.找出问题所在。 I had forgot to add the SERVER_URL in environmental variables in heroku.我忘了在heroku的环境变量中添加SERVER_URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM