Flash Haxe http请求上的安全沙盒冲突
我正在使用Haxe和Flambe库制作一个游戏,目标是flash和html5。我需要通过http请求访问RESTAPI。为此,我使用Haxe的Http类。这是我目前的测试代码:Flash Haxe http请求上的安全沙盒冲突,flash,security,http,haxe,flambe,Flash,Security,Http,Haxe,Flambe,我正在使用Haxe和Flambe库制作一个游戏,目标是flash和html5。我需要通过http请求访问RESTAPI。为此,我使用Haxe的Http类。这是我目前的测试代码: public function getRocketStatus():Void { var urlLoader:Http = new Http("https://seginus-scores.herokuapp.com/api/MailboxMayhem/Highscores/");//"localhost:800
public function getRocketStatus():Void
{
var urlLoader:Http = new Http("https://seginus-scores.herokuapp.com/api/MailboxMayhem/Highscores/");//"localhost:8000/api/rocket");
// add parameters
//urlLoader.addParameter("myVar", "myValue");
//urlLoader.addParameter("userName", "Mark");
// callbacks
urlLoader.onError = function (msg) {requestCompleteSignal.emit(msg);};
//urlLoader.onStatus = function(status) {requestCompleteSignal.emit(Std.string(status));};
urlLoader.onData = function(data)
{
trace('Sending data completed! data=$data');
requestCompleteSignal.emit(data);
}
// sends to data using GET
urlLoader.request();
// sends to data using POST
urlLoader.request(true);
}
每次我尝试使用它时,都会出现以下错误:
*** Security Sandbox Violation *** Connection to https://seginus-scores.herokuapp.com/api/MailboxMayhem/Highscores/ halted - not permitted from http://localhost:7000/targets/main-flash.swf
如果我从Flambe测试服务器、本地apache服务器等使用它,它就不起作用。Flash和html5目标之间似乎没有区别。我也知道跨域策略在我的API上应该是正确的,因为我可以很好地将它与我之前制作的Unity、常规Flash和Java游戏连接起来。
但是,我从html5目标中的js控制台收到以下错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我已经查看了这个Haxe页面,该页面在主题方面有点含糊不清:
我曾经在AS3中做过url请求,不得不处理安全沙箱问题。然而,在这些情况下,将跨域添加到另一端似乎可以解决问题,这与这里的情况不同 好吧,我发现了问题所在。我现在觉得自己很愚蠢。当我使用localhost时,我忘记了在url中添加“http://”(例如
http://localhost:8000/api
)并忘了从上面的通话中删除https,而我只有http可用。请接受您的回答,这样问题就不会悬而未决。