2 Ways to Host Unity WebGL Builds Locally

Posted by Yasthil Bhagwandeen on March 21, 2021 · 1 min read

Introduction

Working with WebGL can be tricky and a simple thing that’s overlooked is hosting a WebGL app locally for debugging. I’ll share 2 easy ways to host a WebGL build locally below.

1. Unity’s Build-and-Run

  • This one is the easiest.
  • All you have to do is go to Build Settings -> WebGL -> Build and Run
    • Unity will host a temporary local sever for your app once it builds!

2. Using Python

  • Install python
  • Change directory to where your Unity WebGL Build resides
  • Run the following command: python3 -m http.server 9090
    • This will host a local http server on port 9090

P.S I tried getting this working using Docker, but it wasn’t as easy as copying the files into an nginx container.