I'm trying to use JS in my origin website to make an AJAX POST to a Cloud Page, that should then write the post data to a Data Extension. The process works well on Postman.

The goal is to retrieve data to be used by customers, and later POST it back to be written with some updates on a second Data Extension.

However, I can't complete the request on my page. Here's a sample of the code I'm using, with Axios (I'm getting the same results using jQuery.ajax()):

edit OBS: Forgot to mention, we've recently got SSL activated in our account.

const handleSubmit = () => {
  const options = {
    headers: {
      'Content-Type': 'application/json',
      'Cache-Control': 'no-cache',
      'Access-Control-Allow-Methods': 'POST',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Headers': 'X-Custom-Header, Content-Type',
        de_name: DATA_EXTENSION_ID,
        email_data: 'test-postman@mail.com',
        PostBody: 'test-postman@mail.com',
    .then(postData => {
    .catch(error => {

And on the Cloud Page itself, I'm setting these as Headers:

Platform.Load("core", "1.1");
HTTPHeader.SetValue("Access-Control-Allow-Methods", "OPTIONS, HEAD, POST");
HTTPHeader.SetValue("Access-Control-Allow-Origin", "*");
HTTPHeader.SetValue("Access-Control-Allow-Headers", "X-Custom-Header, Content-Type");

Finally, here's the resulting error:

Access to XMLHttpRequest at 'https://cloud.n.<domain>.com/<cloudpageurl>' from origin 'https://www.<mydomain>' has been
blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok
  • Not sure, but a pre-flight request is sent via OPTIONS method by the browser. You cloud page does not handle the OPTIONS request type, it handles only POST. – manjit5190 Jul 31 at 9:48
  • Just added it OPTIONS and HEAD, but it did not solve the issue. Thanks for pointing that out! – Eduardo Brito Aug 4 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.