Closed jonathan-taylor closed 8 months ago
Error above is in the JavaScript console.... doesn't appear in the HTML seen in the page.
Yup, the server in this case needs to enable Cross-origin resource sharing (CORS).
Assuming the server is using nginx, you can enable it just for data files with:
location ~* \.(csv|xls|txt)$ {
add_header Access-Control-Allow-Origin *;
}
Or enable it globally across all files with:
location / {
add_header 'Access-Control-Allow-Origin' '*' always;
}
The quickest way forward is to create a data-raw repo on GitHub and enable GitHub Pages as CORS is on by default, c.f.
Thanks, made a github repo for data files. Works fine
From: James J Balamuta @.>
Sent: Wednesday, March 27, 2024 10:32 PM
To: coatless/quarto-webr @.>
Cc: Jonathan Taylor @.>; Author @.>
Subject: Re: [coatless/quarto-webr] [Q&A]: Error with read.csv
(Issue #174)
Yup, the server in this case needs to enable Cross-origin resource sharing (CORS):
You can enable it just for data files with:
location ~ .(csv|xls|txt)$ { add_header Access-Control-Allow-Origin ; }
Or enable it globally with:
location / { add_header 'Access-Control-Allow-Origin' '*' always; }
Perhaps the easiest way forward is to create a data-raw repo on GitHub and enable GitHub Pages as CORS is on by default, c.f.
https://github.com/coatless/raw-data
https://coatless.github.io/raw-data/
— Reply to this email directly, view it on GitHubhttps://github.com/coatless/quarto-webr/issues/174#issuecomment-2024439712, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACTM22ALQ7YP6P6DWXC7BTY2OTOBAVCNFSM6AAAAABFMENXOWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUGQZTSNZRGI. You are receiving this because you authored the thread.Message ID: @.***>
What's your question?
I am unable to download files that I know are publicly readable example
I get an error like:
Access to XMLHttpRequest at 'https://www.stanford.edu/class/stats191/data/schizophrenia.csv' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Is there a config I need to set for this request so that the server doesn't think it's "null"?