POST form to external API

Hi, hoping someone can help me post form data to an external API. This is the demo contact form method from the gatsby-starter-netlify-cms which handles the submission:

handleSubmit = e => {
const form =
fetch('/', {
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  body: encode({
    'form-name': form.getAttribute('name'),
  .then(() => navigate(form.getAttribute('action')))
  .catch(error => alert(error))


I’ve set the action of the form to however, the form is posting to http://localhost:8000/https:/


Hey and welcome :slight_smile: Is this when you test locally or in production? If it’s up and running, could you please share a link to your Netlify URL so we can take a look? If it’s local, I would try pushing to Netlify to see if works there- there might be a local dev step that is prepending localhost to your form action but won’t in production.

Let me know how it goes and we can go from there!


Thanks for your reply. I’ve tried it in Production and it’s the same too. Inspecting the page, the form action is so that’s correct.

Unless you are POSting to Netlify, don’t use that plugin would be my advice. It’s intended to setup a form to POST to us, not to somewhere else. You should write a “normal” form to post elsewhere :slight_smile: