Tiny Thor (made with Monkey X)
Develop on Windows or OSX and deploy easily
Crypt of the Necrodancer (made with Monkey X)
New Star Soccer - BAFTA Winner 2013!!! (made with Monkey X )
Ted - The code editor of Cerberus X
Avalon Legends (made with Monkey X)
Race Time (made with Monkey X)

HttpRequest returns nothing

Holzchopf Jul 4, 2018

  1. Holzchopf

    Holzchopf Moderator Staff Member Moderator CX Code Contributor 3rd Party Module Dev

    Messages:
    263
    Likes Received:
    117
    Trophy Points:
    43
    When I run examples/mojo/mak/httprequest it runs fine. But when I change this line
    Code (Cerberus X):
    1. get_req=New HttpRequest( "GET","https://httpbin.org/",Self )
    to this:
    Code (Cerberus X):
    1. get_req=New HttpRequest( "GET","https://holzchopf.ch/home.xml",Self )
    It stops working. At least in the HTML5 target, in GLFW it keeps working.

    What am I missing?
     
  2. Martin

    Martin Administrator Administrator Moderator

    Messages:
    263
    Likes Received:
    147
    Trophy Points:
    43
    HttpRequest for HTML5 only works when your app runs on the same server where you do the request to. So when you upload your app to holzchopf.ch it should work from there.

    That's a limitation due to that sandbox security stuff...
     
  3. Holzchopf

    Holzchopf Moderator Staff Member Moderator CX Code Contributor 3rd Party Module Dev

    Messages:
    263
    Likes Received:
    117
    Trophy Points:
    43
  4. Martin

    Martin Administrator Administrator Moderator

    Messages:
    263
    Likes Received:
    147
    Trophy Points:
    43
    Haha good question. Actually I have no idea.
     
  5. MikeHart

    MikeHart Administrator Staff Member Administrator Moderator

    Messages:
    1,231
    Likes Received:
    300
    Trophy Points:
    83
    Which browser did you use? Firefox Developer Edition by any chance?
     
  6. Holzchopf

    Holzchopf Moderator Staff Member Moderator CX Code Contributor 3rd Party Module Dev

    Messages:
    263
    Likes Received:
    117
    Trophy Points:
    43
    Opera. On Win10.

    When trying to reach holzchopf.ch, the js console says
    No such message for httpbin.org

    Did a quick research. Because my server doesn't send a 'Access-Control-Allow-Origin' header the browser defaults it's value - which is blocking the response. So without access to the resource server (or more specifically it's config for access control), loading those resources won't work. Too bad =(

    btw. httpbin.org's response header contains 'Access-Control-Allow-Origin: http://localhost:53401'


    Conclusion: Everything works as it should. Which is bad for my because it's supposed not to work the way I wanted.
     
  7. wick

    wick New Member Patreon Bronze

    Messages:
    25
    Likes Received:
    17
    Trophy Points:
    3
    You might not have to have access to the server's config; I think you can just set the access-control-allow-origin header directly on the page you're trying to connect to. I ran into the same problem trying to talk to a php script but was able to fix it by adding this to the top:

    header("access-control-allow-origin: *");

    Dunno how to set headers in HTML, though.
     
    MikeHart likes this.
  8. Holzchopf

    Holzchopf Moderator Staff Member Moderator CX Code Contributor 3rd Party Module Dev

    Messages:
    263
    Likes Received:
    117
    Trophy Points:
    43
    Thank you. I have to look if I can somehow elaborate in my problem.