Streaming live at 10am (PST)

CORS Problem - AJAX


#1

Hi,

I wanna send data with a webflow form to an API using the following script:

 var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.recruitee.com/c/werkenbijvanstraatenpost/careers/offers/scooter-postbezorger-in-heel-nederland/candidates",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
  },
  "processData": false,
  "data": "{\r\n  \"candidate\": {\r\n    \"name\": \"John Smith\",\r\n    \"email\": \"john.smith@example.com\",\r\n    \"phone\": \"987654321\",\r\n    \"cover_letter\": \"Example cover letter\",\r\n    \"remote_photo_url\": \"https://site.example.com/images/myimage.jpeg\",\r\n    \"remote_cv_url\": \"https://site.example.com/resumes/myresume.pdf\",\r\n    \"open_question_answers_attributes\": [\r\n      {\r\n        \"open_question_id\": 5,\r\n        \"content\": \"Yes\"\r\n      },\r\n      {\r\n        \"open_question_id\": 8,\r\n        \"content\": \"Responsibility\"\r\n      },\r\n      {\r\n        \"open_question_id\": 9,\r\n        \"content\": \"Blue\"\r\n      },\r\n      {\r\n        \"open_question_id\": 10,\r\n        \"content\": \"Pizza, Hamburger\"\r\n      }\r\n     ]\r\n  }\r\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Is there a way to avoid to CORS ptoblem so i can use a form on webflow that send data to the following API?

Thanks in advance!

Kind regards,
Edwin


#2

Hi @EdwinN1337, at the moment the ability to setup CORS is not supported natively. You might try to change the script url to originate from a subdomain on your site, i.e. code.yourdomain.com, where “code” is a cname record setup to point to your code server.

The url in that case would be something like:

https://code.yoursite.com/...

I hope this helps


#3

You can use Zapier to make the POST to the server. I personally now use Built.io Flow (enterprise) to make calls from Webflow.


#4

Thanks for the response.

Zapier still not working for me, not sure what i’m doing wrong (error: wrong datarequest).

But im working on it!