Netlify forms submissions not working

I’m having such a hard time getting the Netlify forms detection and submissions working.

My site name is: proof2-web-staging (when I can get this working it’ll be setup on the prod deploy too)

Most of the site is hidden behind login, but I’ve temporarily made the page with the form open to the public:

You’ll need to click the “Get started” button, feel free to enter dummy/testing data on staging

Because the form is normally hidden, I’ve added this page which has a hidden mock version of the form with the same form name and field names. Since adding this, the Netlify forms detection appears to be working:
https://staging.proofplatform.io/_netlify_forms.html

However, when I submit (which I’m doing with a fetch request), the submission never goes through and the POST request just returns the HTML of the home (/) page. The HTTP POST request looks fine/correct to me. Here’s my sending code:

if (validate(submission)) {
	const formData = new FormData(formElement.current!);

	try {
		const result = await fetch('/', {
			method: 'POST',
			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
			body: new URLSearchParams(formData as any).toString(),
		});
		const response = await result.json();
		console.debug('kyc response', response);
	} catch (error: any) {
		console.warn(`Failed submitting KYC verification.`, error.message);
	}
}

To be clear… the code is falling into the catch block because of the attempted .json() call on the response (which contains a HTML document), the HTTP POST request is returning 200 OK but it’s response body is the home (/) page.

I’m not sure what the expected HTTP response is from submitting the form as an AJAX request, but regardless, the submissions aren’t going through to my Netlify dashboard forms screen (in verified or spam submissions)

Hi welcome to the forums. Can you give this forms debugging guide a read and see if this helps?

1 Like

I thought I’d been through everything in all of the forms debugging guides on here, and I had! But I went through everything again and found the solution… it was in this guide:

“Submits fine, yet no submissions in UI” > Point 2 in there mentions SSR, which all of my pages are. I finally fixed it by sending the form submissions to the static HTML page which renders the mock of the form.

Thanks for your help!