godot_web

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 11 Imported by: 0

README

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
Server link: https://192.168.0.100:8000/

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
Server link: http://192.168.0.100:1234/

For a list of all supported options, run:

$ godot_web --help

Requirements

Releases are stand-alone, static binaries with no external dependencies.

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 xv godot_web-0.1.tar.gz
$ cd godot_web-0.1
$ 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/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Dir                  string
	Port                 int
	AllowExternalTraffic bool
	TLSCertFile          string
	TLSKeyFile           string
}

func New

func New(dir string, port int, allowExternalTraffic bool, tlsCertFile, tlsKeyFile string) *Server

func (Server) Run

func (s Server) Run() error

func (Server) ServeHTTP added in v0.2.0

func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL