[SOLVED] Cannot get cvs google spreadsheet because CORS

Hello.

So I’m having a simple spreadsheet for my game for progression and stuff. A couple of month before it worked as a charm, I wrote a simple script that downloads and parses CVS exported google spreadsheet, like so:

        var oReq = new XMLHttpRequest();
        oReq.addEventListener("load", function() {
            var grid = oReq.responseText.split('\n')
            grid = grid.map(function(r) { return r.split(',') })
            
            var row, cell
            
            // ... then i'll do parsing stuff
            
            self.ready = true
            onComplete()
        });
        // real URL, you can copy it and get CVS exported sheet
        oReq.open("GET", 'https://docs.google.com/spreadsheets/d/1w0Q6K4jO4Fko0-i7LTwQdxcOnbJ7U-ZvQkK_TeF_sxg/export?format=csv&gid=0');
        oReq.send();

Current situation is that I try to do that, but instead of CVS I got:

Access to XMLHttpRequest at 'https://doc-0c-00-sheets.googleusercontent.com/export/l5l039s6ni5uumqbsj9o11lmdc/g0ghobgnhfsotqf25ftut96ndg/1593587610000/113439309879225344852/*/1w0Q6K4jO4Fko0-i7LTwQdxcOnbJ7U-ZvQkK_TeF_sxg?format=csv&gid=0' 
(redirected from 'https://docs.google.com/spreadsheets/d/1w0Q6K4jO4Fko0-i7LTwQdxcOnbJ7U-ZvQkK_TeF_sxg/export?format=csv&gid=0') 
from origin 'https://launch.playcanvas.com' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sheet.js:103 GET https://doc-0c-00-sheets.googleusercontent.com/export/l5l039s6ni5uumqbsj9o11lmdc/g0ghobgnhfsotqf25ftut96ndg/1593587610000/113439309879225344852/*/1w0Q6K4jO4Fko0-i7LTwQdxcOnbJ7U-ZvQkK_TeF_sxg?format=csv&gid=0 net::ERR_FAILED

Am I not able to download CVS from playcanvas anymore? It was totally working some time ago (month or two)

Thanks!

Looks like Google may have blocked it? CORS is setup be the server that the resource is on, not the caller (ie PlayCanvas).

See https://stackoverflow.com/questions/62587802/fetching-a-google-sheet-csv-file-yields-cors-error

There’s a CORs checker here too https://www.test-cors.org/#

Seems like you’re right, @yaustar, that’s definitely google’s fault.

So frustrated. Google sheets is one of the best game design tools. At least this approach still works locally.

Yeah, I was actually thinking about using it as a CMS for site. Guess that’s out of the window now :frowning:

Well now you can have cors free reverse proxy for google sheets and other stuff and charge a dollar to use it, perhaps.