GODOT 4.0 / HTML5 Export / CORS
Asked Answered
I

11

0

Hi,

Just to help the community because I have searched few days in godot docs, and on the web.... 🙂
About
1) how to configure apache server in order to contains html5 export godot project
2) how to configure apache server in case of cross domain http requests that exits with 401 error code


1) in case of this message when lauching GODOT4 html5 project on Apache Server

"Error
The following features required to run Godot projects on the Web are missing:
Cross Origin Isolation - Check web server configuration (send correct headers)
SharedArrayBuffer - Check web server configuration (send correct headers)"

you can add in the .htaccess of your server

<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Cross-Origin-Embedder-Policy "require-corp"
Header set Cross-Origin-Opener-Policy "same-origin"
</IfModule>

2) And in order to be able of doing Cross domain request on server that is protected by basic auth
I had to add also in .htaccess

SetEnvIfNoCase Request_Method OPTIONS noauth

<RequireAny>
<RequireAll>
Require env noauth
Require all granted
</RequireAll>
<RequireAll>
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/..../.htpasswd
Require valid-user
</RequireAll>
</RequireAny>

This is needed because preflight htpp requests sended with OPTIONS method (that are launched in case of http requests in cross domains) exited with 401 error code.

This OPTIONS http requests are automatically sent by thepolicy when we code GET or POST 'complex" http request. These OPTIONS http requests do not contain authenticate header...

So this code indicate that the basic auth is not needed for http requests that used the OPTIONS method.

Inconceivable answered 27/3, 2023 at 21:0 Comment(0)
D
0

Since this looks to be a mini-tutorial/guidance post I'll tag it appropriately. Thanks for the contribution. 👍️

Distaff answered 27/3, 2023 at 21:29 Comment(0)
T
0

Thanks, people keep asking about this. Very helpful.

Tirol answered 28/3, 2023 at 0:26 Comment(0)
H
0

does this work with itch io?

Hornwort answered 28/3, 2023 at 4:54 Comment(0)
T
0

You need to change these settings if you're hosting on your own server. Itch has an experimental option to do this, but in my experience it only worked well on Chrome.

Tirol answered 28/3, 2023 at 7:42 Comment(0)
I
0

Hornwort I do not know the possibilities to parameterize itch io server ( and which kind of server are behind itch io).
I have only test that on hostinger (Single Web Hosting solution) : behind it, it is a litespeed web server (an lightweight apache server system).

Inconceivable answered 29/3, 2023 at 19:16 Comment(0)
T
0

Itch is a gaming platform, they don't give you access to the server variables. However they have beta support for this in a check box (I think it's called enable experimental shared buffer).

Tirol answered 29/3, 2023 at 22:1 Comment(0)
I
0

Hornwort Hi, I found this tuto.
If it can help...

Inconceivable answered 2/5, 2023 at 18:52 Comment(0)
R
0

Using this code I'm facing "Domain Refused Connection” error. what should I do?

Raisin answered 21/9, 2023 at 4:37 Comment(0)
S
0

Raisin this code

Please explain in more detail.

Swink answered 21/9, 2023 at 5:35 Comment(0)
R
0

Swink
Trying to fix the error above to run my Godot project, I used the code below like said:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Cross-Origin-Embedder-Policy "require-corp"
Header set Cross-Origin-Opener-Policy "same-origin"
</IfModule>

But when I want to run my game, I still encounter an error that says my domain refused connection and I don't know what should I do.

Raisin answered 21/9, 2023 at 6:59 Comment(0)
S
0

On my web server account, which runs Apache and permits .htaccess files, I created an .htaccess file with these contents, and it fixed the problem reported in the initial post of this thread:

Header set Cross-Origin-Opener-Policy "same-origin"
Header set Cross-Origin-Embedder-Policy "require-corp"

However, Godot 4 HTML5 exports require the HTTPS protocol, and I don't have a security certificate, so a user visiting the page gets a warning message about the missing certificate.

The above problems are avoided when I upload the project to itch.io.

Swink answered 21/9, 2023 at 7:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.