Skip to content

minimalistic webserver for testing Godot HTML builds

License

Notifications You must be signed in to change notification settings

pipejakob/godot_web

Repository files navigation

godot_web

build test

godot_web is a minimalistic webserver for testing Godot HTML builds.

Why?

Prior to Godot 4.0, HTML builds could be tested using python -m http.server or other simple webservers. However, projects exported to HTML via Godot 4.0 now require the use of Javascript SharedArrayBuffers, which are disabled in modern browsers unless specific policy headers are set by the webserver to ensure they can be enabled securely.

You'll know you're in the right place if you see errors like this when trying to access your builds from a browser:

image

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)

Usage

To get around these errors, just run godot_web in the same directory as your Godot project build:

$ godot_web
Server link: http://127.0.0.1:8000/

Then, open the link in your browser to access your build. godot_web will serve your project files and add the appropriate Cross-Origin HTTP headers so that SharedArrayBuffers can be enabled securely.

By default, this server will only accept requests from localhost, so it will not be accessible from remote computers. To change this behavior, you can allow external traffic via the --external flag:

$ godot_web --external

Note: when the --external flag is given, godot_web will generate a self-signed TLS certificate to serve traffic over HTTPS, which is another requirement of Godot 4.0 HTML builds that aren't accessed via localhost. If you want to use your own certificate and private key instead, use the --tls-cert <FILE> and --tls-key <FILE> flags.

Don't like the default port (8000)? Override it with --port <PORT>, like:

$ godot_web --port 1234

Want to serve content from a different directory? Specify it as the last argument:

$ godot_web --port 1234 ~/projects/godot/mygame

For a list of all supported options, run:

$ godot_web --help

Requirements

Releases are stand-alone, static binaries with no external dependencies. You can download and run them on Linux, Mac, and Windows without any other requirements.

Building

If you prefer to build from source, you will need go >= 1.18.

To build the latest version from git, you can clone this repository and run make from its root:

$ git clone https://github.com/pipejakob/godot_web.git
$ cd godot_web
$ make

Or, you can download the source code of a specific release, unpack it, and run make there:

$ tar xf godot_web-0.2.0.tar.gz
$ cd godot_web-0.2.0
$ make

Running make from the project root will build the godot_web binary in the current directory.

Installation

To install, run:

$ make install

and the godot_web binary will be placed into $HOME/go/bin (make sure this is in your $PATH!).

If you want to install it system-wide, you can copy the binary to a system folder, like:

$ make
$ sudo cp godot_web /usr/bin/

About

minimalistic webserver for testing Godot HTML builds

Resources

License

Stars

Watchers

Forks