I have a Google spreadsheet and a Google script app that has method doGet(e) which returns spreadsheet content in JSON. Google app is published, and by calling URL I receive totally valid JSON i'm looking for.
Now, I'd like my Chrome extension to call that URL and receive all the data.
It's been working a while ago, but as of this moment, it crashes with an error
Access to XMLHttpRequest at 'https://script.google.com/macros/s/XXX/exec' from origin 'https://www.YYY.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've been digging around for a while, tried several solutions, but it seems most of them are related to the backend, which I don't have access to (its still Google script app). Are there any workarounds?
EDIT: no luck with that option. My code (tried application/x-www-form-urlencoded, multipart/form-data, text/plain - got the same results):
$.ajax({
url:'https://script.google.com/macros/s/XXX/exec',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
},
success:function (result) {
***
}
Thanks to Tanaike for a great hint!
Apparently, the issue was in publishing settings. Basically, I did 2 steps to solve it: