Im using Google Apps Script, and Im just trying to connect from the javascript in the front end to the Google Script but I keep getting CORS errors.
Access to XMLHttpRequest at 'https://script.google.com/macros/s/KEY/exec' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
In the JS I have this
var email = $('#ID_EMAIL').val();
$.post("https://script.google.com/macros/s/KEY/exec",
{
email: email
},
function (data) {
console.log("success");
}, 'json');
and in the GAS
function doPost(e) {
return "hello";
}
I dont know why i keept getting the error if it just a basic code.
I have publish the google sheet as a web page, and the GAS as a web applications public to anyone.
I dont know what Im missing
Access-Control-Allow-Origin *
to the post request? – evolutionxbox