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 “” to “” 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">
    <meta charset="utf-8">
    <title>Download Github Asset Test</title>
        const githubApi = "";

        async function fetchAsset(filename) {
            const release = await fetchJSON(githubApi + "/releases/latest");
            for(const asset of release.assets) {
                if( == filename) {
                    const url = githubApi + "/releases/assets/" +;
                    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");
                document.body.innerText = "Fetch okay";
            } catch(e) {
                document.body.innerText = "Fetch failed";
  <body onload="javascript:onLoad()">