Glossary

CORS explained.

CORS (Cross-Origin Resource Sharing) is the browser rule set that lets a page on one origin send a fetch or XHR request to an API on another origin, using response headers to grant permission.

Definition

How CORS works

By default a browser enforces the same-origin policy, which stops JavaScript on one origin (a scheme, host and port, like https://yoursite.com) from reading responses off another. That protects users, but it also blocks legitimate calls, such as your site's fetch request to an API on a different domain. CORS is the agreed way to relax that safely.

When your script makes a cross-origin request, the browser attaches an Origin header naming where the call came from, and the server answers with an Access-Control-Allow-Origin header saying which origins it trusts. If your origin is allowed, the browser hands the response to your code, otherwise it blocks it. For anything beyond a simple request the browser first sends a preflight, an automatic OPTIONS check that asks permission before the real call goes out. Crucially, CORS is enforced by the browser, not the server, and it governs whether your script may read the response.

For a form backend this is why a fetch submission to the endpoint just works: FormWire returns permissive CORS headers, so a script on any static site can POST to the endpoint and read the result without a proxy of your own.

Related questions

Want to see it working?

Read the docs
Ready in a minute

Post to your endpoint from any origin.

Free tier forever. No credit card required.