【问题标题】:Security Sandbox violation on Haxe http requestHaxe http 请求的安全沙箱违规
【发布时间】:2014-06-08 12:15:27
【问题描述】:

我正在使用针对 flash&html5 的 Haxe 和 Flambe 库制作游戏。我需要使用 http-requests 访问 REST-api。为此,我使用 Haxe 的 Http 类。这是我目前的测试代码:

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-target 的 js-console 收到以下错误:

 No 'Access-Control-Allow-Origin' header is present on the requested resource.

我已经查看了这个 Haxe 页面,该页面在主题方面有点模棱两可: http://old.haxe.org/doc/flash/security

我以前在 AS3 中完成了 url-requests 并且不得不处理安全沙盒问题。但是,在这些情况下,将跨域添加到另一端似乎总是可以解决问题,这与这里不同。

【问题讨论】:

    标签: flash security http haxe flambe


    【解决方案1】:

    好的,我找到了问题。我现在觉得很傻。我在使用 localhost 时忘记在 url 中添加“http://”(例如 http://localhost:8000/api)并且忘记从上面的调用中删除 https,而我只有 http 可用。

    【讨论】:

    • 请接受您的回答,这样问题就不会悬而未决。
    猜你喜欢
    • 1970-01-01
    • 2011-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 2011-08-06
    • 1970-01-01
    相关资源
    最近更新 更多