0 votes

I'm trying to export my program for HTML5. Whenever I try testing it in a browser, all HTTP requests fail with the response RESULT_CONNECTION_ERROR = 4 --- Request failed due to connection (read/write) error.
HTTP requests work fine when exported for desktop and Android.
I get the same error on Chromium and Firefox.
The error persists whether I'm connecting to my development server or google.

Godot version 3.5.5
in Engine by (85 points)
edited by

From the documentation:

Note: When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to CORS. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the Access-Control-Allow-Origin: * HTTP header.

Maybe this is your issue? I got the text above from Making HTTP Requests -> HTTPClient

Thanks, but I don't think CORS is the issue because I have the same problem when trying to connect to my development server and google.

Unless there is a setting within Godot that may affect it, I don't see how I can make any impactful changes.

You are actually correct. Checking the errors in my browser, it says that CORS is preventing access to my server.
Thank you for your help.

1 Answer

+1 vote
Best answer

Converting my comment to a question:

From the documentation:

Note: When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to CORS. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the Access-Control-Allow-Origin: * HTTP header.

This is your issue! I got the text above from Making HTTP Requests -> HTTPClient

by (246 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.