云代码的解析服务器问题

Parse-server problems with cloud code.

本文关键字:服务器 问题 代码      更新时间:2023-09-26

我已经将解析服务器部署到heroku(mLab.com 作为数据库),但是云代码遇到了一些问题。

当调用"hello"函数时,一切都可以正常工作。

调用"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.

一直在玩猫,没有任何运气。任何建议将不胜感激。

------------ 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);
    });
});
找出

问题所在。我忘了在 heroku 的环境变量中添加SERVER_URL。