I was making a web app using google apps script, and I have been getting errors like this:
Access to CSS stylesheet at 'https://script.google.com/.../exec?url=style.css' from origin 'https://...-script.googleusercontent.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to script at 'https://script.google.com/.../exec?url=script.js' from origin 'https://...-script.googleusercontent.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how would I add an Access-Control-Allow-Origin header?
function doGet(e){
var t,r;
//...
if(t=='text/html'||t=='text/x-server-parsed-html'){return HtmlService.createHtmlOutput(r);}
r=ContentService.createTextOutput(r);
r.setMimeType(ContentService.MimeType.TEXT);
if(/[^\/]+?\/([^.]+?\.)?([^+]+?\+)?xml/.test(t)){r.setMimeType(ContentService.MimeType.XML);}
if(t=='application/atom+xml'){r.setMimeType(ContentService.MimeType.ATOM);}
if(t=='text/csv'){r.setMimeType(ContentService.MimeType.CSV);}
if(t=='text/calendar'){r.setMimeType(ContentService.MimeType.ICAL);}
if(t=='application/javascript'||t=='text/javascript'){r.setMimeType(ContentService.MimeType.JAVASCRIPT);}
if(t=='application/json'){r.setMimeType(ContentService.MimeType.JSON);}
if(t=='application/rss+xml'){r.setMimeType(ContentService.MimeType.RSS);}
if(t=='text/vcard'){r.setMimeType(ContentService.MimeType.VCARD);}
if(e.parameter.name){r.downloadAsFile(e.parameter.name)}
return r;
}
simplerequests that doesn't need to be preflighted.