Priority: Not Evaluated
Affects Version/s: None
Fix Version/s: None
This task documents a local web server setup for use when developing with Qt for WebAssembly. The requirements are:
- Small and modifiable implementation. Easy to use.
- Use secure sockets. Many new web features now require a secure context. “localhost” (over http) is in some cases considered a secure context, but may not always be so.
- Serve from “localhost”, but also from the machine’s public ip, which enables access from other devices.
- Ability to set custom headers (e.g. for enabling threading/SharedArrayBuffer)
Note: Please evaluate the security implications of installing a certificate authority and running a web server on a public IP as it applies to your setup before using this solution.
1. Install mkcert and install the certificate authority: See https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/
The CA can be installed on other devices: Run “mkcert” to print the location of the CA, then install the rootCA.pem file (e.g. email it to yourself and open it on the device)
2. Run pyserver.py (code provided below):
The script will
- Generate certificates for “localhost” and the current public ip
- Serve the current directory on “localhost” and the current public ip, at the given port
- Set required extra headers
(edit the script as needed)