HTML5 + Networking behaviours

ArmellineArmelline Member, PRO Posts: 5,334
edited September 2023 in Working with GS (Mac)

Is this working currently? I'm getting no response to networking requests that work in Creator and on device. This is pretty urgent. @adent42

Comments

  • ArmellineArmelline Member, PRO Posts: 5,334

    Ah I just rememebered about the CORS stuff. Guess I have to relearn all that.

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,067
    edited September 2023

    While you're developing I find the easiest thing is to open it all up. For instance we're using FastApi in our glitches and we just do:

    app.add_middleware(
      CORSMiddleware,
      allow_origins=["*"],
      allow_credentials=True,
      allow_methods=["*"],
      allow_headers=["*"],
    )
    

    Which translates to the headers:

    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: *
    Access-Control-Allow-Headers: *
    Access-Control-Allow-Credentials: true
    


  • ArmellineArmelline Member, PRO Posts: 5,334

    For this project I don't have direct access to the glitch so this is still up in the air for me but much appreciated, will pass it on and bookmark for inevitable later use!

  • ArmellineArmelline Member, PRO Posts: 5,334

    It turned out to be more than CORS that was causing problems and I'll give a brief explanation here for anyone else having this issue. If you write your own server code there's a good chance you'll bypass it, but I was lazy and using the Glitch server python code that was provided, which has always worked a treat for me with iOS/Android published games.

    When Creator etc. send a POST request (network send table) they include a sig in the request. When HTML5 sends one it does not.

    I don't know if there's somewhere I could or should have added one in the HTML5 project, but once the requirement is removed from the Glitch server code, it accepts POSTs from HTML5 published projects just fine.

    GET / network get table is not affected by this.

  • uptimistikuptimistik Key Master, Member, Sous Chef, PRO Posts: 255

    Nice one @Armelline appreciate the explanation as to what was causing your issue.

    GameSalad Templates and Custom Development at the Official Marketplace: http://gshelper.com

Sign In or Register to comment.