How-to · Checked November 22, 2026

How to fix a CORS error when submitting a form

A CORS error means your page used JavaScript to call an address on another origin, and the response did not carry a header allowing your page to read it. The fix is always on the receiving server, or in the address you are calling. It cannot be switched off from your page.

A plain HTML form post never hits CORS. If you only need the form to send, removing the JavaScript and using a normal action is a valid fix.

What CORS is checking

Browsers stop scripts on one site from reading responses from another site unless that other site agrees. It agrees by sending an Access-Control-Allow-Origin header that names your origin or is a star.

Some requests are also checked before they are sent. A fetch with Content-Type: application/json or with custom headers triggers a preflight: the browser first sends an OPTIONS request, and the server has to answer it with the methods and headers it allows. A fetch whose body is FormData and whose only extra header is Accept needs no preflight.

Find the real cause

  • Open the Network tab and look at the failing request. The status code tells you more than the console message.
  • A 404 or 500 with a CORS message usually means the address is wrong or the server crashed. Error pages often lack the header, so the browser reports CORS when the real problem is something else.
  • A redirect, for example from http to https or to a different host, can lose the header on the way. Call the final https address directly.
  • A failed OPTIONS request means the server does not answer preflights. Send FormData in place of JSON, or fix the server.
  • An origin of null means you opened the page as a file. Serve it from a local web server.

Fixes that work

  • Correct the address: full, https, no typo in the form id.
  • Send a simple request: body: new FormData(form) and no Content-Type header of your own.
  • If the receiving server is yours, make it send Access-Control-Allow-Origin on every response, including errors, and answer OPTIONS requests.
  • Use a receiver that is built to be called from browsers on other sites, such as a form backend.
  • Or drop fetch and let the form post normally with an action and method="POST".

Fixes that do not work

  • mode: 'no-cors'. It hides the error by making the response unreadable, so your code cannot tell success from failure, and it does not allow JSON bodies.
  • Adding Access-Control-Allow-Origin to your own request. It is a response header and does nothing when sent by the browser.
  • A browser extension that disables CORS. It only changes your own browser, not your visitors'.
  • A public CORS proxy. It passes your visitors' data through someone else's server.

With FormTango

Requests from any website are allowed on form endpoints, the addresses that start with https://formtango.com/f/. Both FormData and JSON bodies are accepted. So a CORS error against a form endpoint usually means the request did not reach it as written: check the address first.

The account API under /api/v1 is different. It needs an API key and refuses calls from another website's browser page, by design. Call it from a server or script. More cases are on the troubleshooting page.

A request that works

const response = await fetch('https://formtango.com/f/YOUR_FORM_ID', { method: 'POST', headers: { Accept: 'application/json' }, body: new FormData(form) });

The surrounding code is in how to submit a form with fetch.

Common questions

Why do I get a CORS error with fetch but not with a normal form?
CORS only limits scripts reading responses from another site. A normal form post is a page navigation, which browsers have always allowed across sites, so it is not checked.
Can I fix a CORS error from the front end?
Only by changing what you request: the right address, or a simpler request. The permission itself is a header the server sends. No setting in your page can grant it.
Does mode no-cors fix the problem?
No. The request may be sent, but the response is opaque, so your code cannot read the status or body. You lose the ability to show a true success or error message.

Written by the FormTango team. Facts about other services were read from their own pages on November 22, 2026. Spotted something out of date? Tell us and we will fix it.

Keep reading