If rg finds nothing in a folder where I am sure the text exists, the cause is usually that ripgrep is being polite.
By default it skips files that your .gitignore lists, hidden files and binary files. Each -u switches off one of those filters:
rg -u 'API_KEY' # also searches ignored files
rg -uu 'API_KEY' # also searches hidden files such as .env
rg -uuu 'API_KEY' # also searches binary files
That is how a hit in a .env file shows up when the plain search says nothing.
Caveat: -uu walks into folders like node_modules as well, and the output gets long. Cut them out with rg -uu -g '!node_modules' 'API_KEY'.
Further reading: ripgrep user guide
Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get