Cannot fetch release asset binary via Javascript

I am trying to build a client-side web page that can help the user find the appropriate asset from a release I made on github. I was able to use the GitHub API to locate the asset, but when I try to fetch the binary contents of the asset, the request is redirected away from “api.github.com” to “github-releases.githubusercontent.com” and Javascript throws an exception due to CORS. I am attaching a sample HTML file that illustrates the problem.

Is there any workaround that allows me to do this? Using “no-cors” is not an option for me as I need to be able to process the reply.

The only alternative I see right now is pushing my binary assets into gh-pages, rather than releases, but obviously this is not ideal as it will cause the repo to become very bloated over time.

Example test case:

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Download Github Asset Test</title>
    <script>
        const githubApi = "https://api.github.com/repos/drunken-octopus/drunken-octopus-downloader";

        async function fetchAsset(filename) {
            const release = await fetchJSON(githubApi + "/releases/latest");
            for(const asset of release.assets) {
                if(asset.name == filename) {
                    const url = githubApi + "/releases/assets/" + asset.id;
                    return fetchFile(url, {Accept: "application/octet-stream"});
                }
            }
        }

        async function fetchJSON(url, options) {
            const response = await fetch(url);
            if (response.ok) {
                return response.json();
            } else {
                throw new Error("Failed to fetch \"" + url + "\" (" + response.status + ")");
            }
        }

        async function fetchFile(url, headers) {
            const response = await fetch(url, {headers});
            if (response.ok) {
                return response.arrayBuffer();
            } else {
                throw new Error("Failed to fetch \"" + url + "\" (" + response.status + ")");
            }
        }
        
        async function onLoad() {
            try {
                const file = await fetchAsset("index.json");
                console.log(file);
                document.body.innerText = "Fetch okay";
            } catch(e) {
                document.body.innerText = "Fetch failed";
            }
        }
    </script>
  </head>
  <body onload="javascript:onLoad()">
  </body>
</html>