-
Notifications
You must be signed in to change notification settings - Fork 907
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
No 'Access-Control-Allow-Origin' header is present #154
Comments
After further research, I believe my initial suspicion is correct - I had forgot to mention in my initial post that I am viewing this webpage locally (i.e. by opening a tab through my text editor) and that, combined with the fact I am on a work domain/network, is the reason why I expect that error to be thrown. For anybody else who stumbles across this issue and still has difficulty understanding why, I'd recommend looking up CORS |
@mskusek Thanks for updating! Glad you were able to figure it out. I think it might be worth adding a troubleshooting section to this tutorial to capture all the great content from the issues that have been solved. What do you reckon @mckennapsean ? |
Many people have had CORS issues over the years. @mskusek thanks for posting an update! what was your final solution? did you just host the index.html file on a server and run from there, or...? @iteles I made a PR for improving the tutorial a while back, adding a section on FAQ's. If we can pinpoint the proper solution, we can post this in there too! #148 Feel free to take a look & review! I was waiting a bit to hear from others, but may pull in soon otherwise. |
@mckennapsean For a temporary fix, I simply created another Google account that wasn't part of my work's domain and am doing my testing/debugging through that. Once I have additional access at my work, I'll try linking my web app and google work domain - I will post updates when I get any! |
same here, I have the exact problem when I implement the ajax request and I'm trying the functionality from local. |
@sebalaini If you're working on a work network like I am, the only way around it is working with your network administrator and everything that entails. You could look up additional information on CORS but for some of the solutions I've found, they pose security threats and the last thing I would want to do is put my workplace at risk. |
I have encountered this one but the cause of the error was the handler is looking for the id="thankyou_message" so what i did is put the code stated referring to id="thankyou_message" and the error is gone. Hopefully it helps for an idea. Thank you! |
@mskusek Thanks, I solved :) was an error with the permission of Google sheets and I didn't copy the exact code as in the html here in the repo. |
For the OP & others with the issue, I have a work GSuite domain now, so I can test this in the near future. I plan to do so. I will keep others posted of any updates, solutions, and gotchas as I go. |
For those with GSuite or Google Enterprise accounts, I could not replicate these issues locally with my account. As a note, the script URL that is given when you have multiple accounts signed in (e.g. a GSuite and a personal Google account) includes a |
I have tested some more and found this error when: A) you have improper permissions set. check step # 5 again, it absolutely must be set to "Anyone, even anonymous" or this cannot work. -or- B) when you have multiple google accounts logged in when publishing the form, the URL given will include the user id in it, i.e. Lastly, we need to fix the form, since the form happily submits (and has a thank you page) even when these errors occur which is not good. |
I hadn't specified the data attribute in html, now m getting the console of success, but not getting email or a response for the data sent. |
Which data attribute was that? This issue sounds tangential to the one here, and not really easy to reproduce without an example. I would suggest looking back at the steps, especially the ones highlighted above, watch your console for errors, and use sites like StackOverflow to your advantage. |
I had the issue, I will tell you why the issue was raised in my case and how I fixed it : I was sending data using How to fix this : Simply sets the following header var formData = new FormData();
formData.append("email", "test@example.com");
formData.append("message", "Hello");
// Send formData as the body with your HTTP library (JQuery, XMLHttpRequest, or wathever)
// Dont forget to set the header Content-Type: application/x-www-form-urlencoded |
thanks for posting that @SlaAls ! that is very insightful and useful. is this a result from not using our provided clientside JS? we have the XMLHttpRequest header set to that in our code. perhaps the main issue is that people using the site without the Javascript (or if there are errors in the Javascript console causing it to never run - aka, same as not having it loaded) --> thus they are submitting the form with a json header in the POST request? |
The OP was posting a CORS issue from the Google script... not the GitHub script we provide. This is an important distinction if you have a similar problem, which script is causing it? I recently discovered that we are actually hosting the GitHub file from another site (RawGit) that corrects CORS headers on GitHub files. So I would be baffled if you are using our script and getting that. I am less certain on the Google side unless you are sending a mangled/incorrect header to the Google Script in the first place (as mentioned above). |
hi!
my solution is to create a new copy and deploy it, you will recieve a new link, |
Glad to hear you found a solution - thanks for posting @4edorov ! |
this thread has varied from one issue to the next, with large variability of the underlying issue. is it a CORS issue from Google's side? from a local JS script? is it limited to a GSuite account? I have tried to reproduce and only seen errors which I posted fixes for above. in all of those cases, it was the result of someone not following the tutorial correctly. if there are still problems let's make new, more specific issues to which of those cases above it affects. |
oh and I did just require people copying the repo to use their own local JS instead of loading one from Git, which could solve one of these cases. #240 |
I have the same problem, tried this but it didn't work for me. |
just add to request: async function sendRequest(){
const url = 'https://';
const requestOptions = {
method: "POST",
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ title: "some data" })
};
let response = await fetch(url, requestOptions);
let data = await response.text(); //or .json()
console.log(data); |
Thank you |
Hello!
First of all, I wanted to thank you for this tool - it's great! I am having some trouble with one particular problem, however. When I go to submit the form, I get my "submission successful" prompt on my webpage but notice no e-mail is sent and nothing is logged on the excel sheet. I checked the console and found this:
I am working on a work network so I'm thinking there might be trouble with a Google Apps Script trying to communicate with my CalendarTest.html - any easy way around this or will I have to setup a local server?
The text was updated successfully, but these errors were encountered: