Allowed domains
The list of sites a form belongs to. It decides where a redirect may send people, and which origins a browser-restricted form accepts.
What the list does
Each form has a list of allowed domains under Allowed domains in its settings. The endpoint uses it for two things:
- Redirects. After a plain HTML post, the browser is only sent to a
_mtf_redirectaddress whose domain is on the list. Anything else lands on the plain success page. This is what stops your endpoint being used as an open redirect. - Origin checks. As soon as the list has a domain, the form refuses any browser submission whose
Originheader is not on it, withorigin_not_allowed(403). Remove the last domain and the form accepts posts from anywhere again.
Origin header (a Next.js Server Action, a cron job, curl) gets origin_not_allowed. Send server-side submissions to the API with a secret key, which origin checks do not apply to.- 1
Add your domain
Open the form, go to Settings, and type the domain into Add allowed domain. You can paste a bare domain or a full URL; it is stored as an origin, meaning scheme, host and port, with any path dropped.
You type Stored as example.com https://example.com https://www.example.com/contact https://www.example.com http://localhost:3000 rejected: needs a dot in the host http://staging.example.com:8080 http://staging.example.com:8080 Matching is exact.
https://example.comdoes not coverhttps://www.example.comorhttp://example.com, so add each one your pages are actually served from. - 2
Send people to your own thank-you page
Add the hidden
_mtf_redirectfield with an absolute URL on one of those domains. After a successful post the browser gets a303to that address.HTML<form action="https://mtform.co/f/your-form-key" method="POST"> <input type="hidden" name="_mtf_redirect" value="https://example.com/thanks"> <label> Email <input type="email" name="email" required> </label> <button type="submit">Send</button> </form>The path and query string are kept; a
#fragmentis dropped. Relative URLs, non-HTTP schemes and URLs with a username or password in them are ignored, and the visitor sees the plain success page instead. - 3
Check it
Submit the form from your site. If you land on the plain success page rather than your own, the redirect's origin is not on the list: compare scheme,
wwwand port character for character.JSON callers are never redirected. A request sent withAccept: application/jsongets the JSON body whatever_mtf_redirectsays. Navigate in your own code after a successful response, as the fetch guide shows.
When an origin is refused
On a browser-restricted form, a post with no Origin header, or one not on the list, is refused before its body is read. A JSON caller gets:
| Code | HTTP | Message |
|---|---|---|
| origin_not_allowed | 403 | This form does not accept submissions from that address. |
Server-to-server calls made with an API key skip the origin check entirely, because a backend has no meaningful origin. See server-side submissions.