Disabling PWA for Discourse Forum sofware

tl;dr: set SiteSetting.pwa_display_browser_regex = ".*"

At Prospero Health, we've been working on a moderated community forum, and we've been using Discourse to run it.

For various reasons, we wanted to remove the PWA manifest that Discourse ships with by default. PWA manifests are normally a good thing, but in our case they muddy the waters for our users.

As of the writing date, the only information surfaced by Google was a Discourse Meta post with a suggestion to mess with the manifest. This was a messy solution when it worked in 2022. In any case it doesn't work now.

In addition to all the site settings Discourse exposes in the admin section, there are other hidden ones that you can use to tweak behaviour. It turns out there is one for just this purpose: pwa_display_browser_regex.

pwa_display_browser_regex is a regex value that Discourse compares the browser's User-Agent string against. If it matches, Discourse will provide a PWA manifest that sets the display mode to browser (ie, normal/default). Its default value is something that will match nothing: a^

By flipping that inside out, and setting the value to .* (which matches everything) we were able to turn off PWA for our forum without having to create any custom code.