【发布时间】:2016-04-28 08:39:33
【问题描述】:
我已将解析服务器部署到 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.
一直在玩 cors 没有任何运气。 任何建议将不胜感激。
------------ 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);
});
});
【问题讨论】:
标签: javascript parse-platform parse-server