I now have this working for self-hosted gitea, forgejo and gitlab instances. Also for many hosted solutions eg bitbucket.org, sourcehut and lauchpad.net. It turns out that a lot of services redirect https://domain/repo/raw/HEAD/README.md to the raw file with CORS enabled.