Fetching a Google Sheet csv file yields CORS error

Viewed 1948

I try to tech data from a Google spreadsheet using this code

function init() {
    Papa.parse(public_spreadsheet_url, {
      download: true,
      header: true,
      complete: showInfo
    })
  }

This yields the following CORS error:

Access to XMLHttpRequest at 'link to shared Google Sheet CSV' from origin 'my domain' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

2 Answers

It looks like Google has changed something in the last few days. This is preventing sites from linking direct to a Google Sheet. You will need to cache the file using a remote service to get around the CORS issue.

A service like https://cors-anywhere.herokuapp.com will do the job but there are request limits.

Related