WiFi Connect SSID visible AND connects, but the captive portal is not served

Background:
I’ve setup my Raspberry Pi 4 B with BalenaOS. For context during the flashing process I chose to define “WiFi + Ethernet” (and provided a the SSID and passphrase for a local WiFi network).

I then created this git repo: GitHub - hilibari/balena-wifi-connect-not-working

I would really appreciate some help troubleshooting my issues with setting up wifi-connect.

My situation:
When I turn on my Raspberry Pi 4B it automatically connects to the preconfigured local network. I then use the Terminal within BalenaCloud to run nmcli connection down id "localNetworkNameGoesHere" on the Host. This successfully disconnects the Raspberry Pi 4B from the local network; it also successfully triggers the wifi-connect to broadcast the “WiFi Connect” SSID and it also successfully allows me to connect to the “access point”. However, I automatically get redirected to a broken page – a page that is empty (see screenshot below).

What can I do to solve this issue? Are there any errors inside my git repo?

Screenshot of broken page:

Try removing sleep infinity from your start.sh script.

Did you have any luck getting this to work? I’m having the same issue. Also didn’t have any joy removing sleep inifinity from the start script.

Looks like this is my issue:

Works if you copy the implementation set here: