Httprequest fail to retrieve an image when the project is exported to HTML5

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ea4evb

Hi everyone!
I’m newie in Godot and I’m stuck with this.

I have a scene that loads an image from a web server via HttpRequest. The image is loaded into a new texture and assigned to a TextureButton.
Here is the code:

   func _ready():
$HTTPRequest.connect("request_completed", self, "_http_request_image_completed")

func _http_request_image_completed (result, response_code, headers, body):
var image =
var image_error = image.load_png_from_buffer(body)
if image_error != OK:
     print ("Can't show the image")
var texture =

Everything works fine when it runs on the debugger or even when is exported to android, but when I try to export the project to HTML5 I’ve got a result_code 4 that means “RESULT_CONNECTION_ERROR = 4. Request failed due to connection (read/write) error.”

I have tried accessing images that are served in both https and http with the same result when the project is exported to HTML5.

I would appreciate any help.

Many thanks in advance.
Godot 3.2.1

do you have the project online somewhere?

Try this:

  1. open the browser
  2. hit F12 to open debugger
  3. open the network tab
  4. open the html5 project in the browser
  5. look for the request
  6. look in the console for any error messages

Maybe the browser blocks the request because of cross-origin-policy.
Same-origin policy - Security on the web | MDN

klaas | 2020-07-09 16:42


That’s it. I’ve uploaded the image in a localserver that has the header Access-Control-Allow-Origin: *. Now the image is shown in the scene.

Many thanks!

ea4evb | 2020-07-10 08:19