If hosting on Cloudflare Pages is acceptable, the cloudflare-pages-auth github repo contains instructions on how to set up the cloudflare actions to block access to the site via middleware functions.

Hosting Setup:

  1. Create a CFP_PASSWORD environment variable on the build platform containing the password you would like to use.

Advantages

  • Unlike using Staticrypt, enableSPA can be left enabled (true), resulting in a smoother browsing experience.

Limitations