Disallow: / on your API host makes Google see your SPA as empty
- Field note
API URLs were showing up in Google, so I added Disallow: / to the API host. Google then rendered the site without being allowed to fetch its data, and got the empty shell. It stayed like this for three weeks.
Robots rules control crawling, not indexing. Google's documentation says robots.txt "is not a mechanism for keeping a web page out of Google" and recommends noindex. It also warns against blocking resources a page needs to be understood. A crawler has to be able to fetch the URL to see the noindex header at all.
To confirm: in Search Console, go to URL Inspection, Test Live URL, View Tested Page, More Info, Page Resources. The API calls are listed there as blocked by robots.txt.
Cloudflare also cached robots.txt with max-age=14400 in my case, so the old file can keep being served for up to four hours after a deploy. Measure with and without a cache-busting query.