Form submission return URL sometimes errors with Page Not Found

I have some forms submitting on the site and the return URL is set to /thank-you

When you visit this page normally, it shows up fine. But when the form redirects to it, sometimes it comes up with the Netfliy Page Not Found error. Is there a reason for this and any way to prevent it from happening? It is very intermittent and only shows the error sometimes. Other times it works okay.

The form POSTs to an external URL which then returns the user back to the thank-you page. Not sure if this is related to the issue?

Just worth nothing that this is a custom form, not a netlify form.

Thanks,

hi, do you have a link to your live form you can share? also, can you explain a little more what you mean by “custom form”?

Hi Perry,

Sure, link to the live form is https://alliance-investments.com/contact/

If you complete any test submissions, please prefix your name with TEST_ so that the client and filter it out of the submissions.

By custom form, I simply mean that it is not a ‘Netlify Form’. It is a form that is generated through the CMS of the site via a third-party plugin called Freeform.

It is worth mentioning too, when you are on the 404 page, if you click on the browsers address bar and hit return, it will reload and show the correct page. So the page definitely exists.

The form submissions are going to a CRM. This means that the POST URL of the form is https://go.alliance-investments.com/l/577541/2019-10-30/gwgb4q

I wonder if there is something causing the issue with the browser redirecting from that domain back to the Netlify server.

Before we ran the site on Netlify, this was all working okay. The issue has only become apparent since switching to Netlify.

hi there, sorry to be slow to get back to you, i think i understand what is happening - your form is being handled on a non-netlify server somewhere that then redirects back to the /thank-you page when it is done handling the form, but that these requests sometimes cause a 404, is that correct?

When you say that this worked before you ran the site on netlify, can you be more specific? do you mean you were able to run this locally, or was it live somewhere?

Yes that is all correct.

When we originally launched this is, we did not run it on a Netlify server. During this time, the form redirects worked correctly, and never brought up a 404 error on the thank-you page.

It is only since we have moved the site onto Netlify that this error has become an issue.

I see you have the following redirect here:

/thank-you /thank-you/ 301

Is there a reason for that? Note that you won’t be able to do that as mentioned here. Can you try removing that rule and see if that improves your issue?

I added that redirect as an attempt to ‘fix’ the issue - the 404 was showing up prior to this redirect being in place.

For SEO reasons, we need to have trailing slashes at the end of all URLs. So it was an attempt to try to redirect from /thank-you when it was erroring on submission, to /thank-you/ which loads correctly. Obviously a bit hacky, but it didn’t resolve the issue anyway, so might as well remove it.

1 Like

I initially overlooked the issue, but it looks like you are setting your action as some url that is not part of your netlify-hosted site. The action needs to be an existing page on your netlify-hosted site. For example, you have a /thank-you/ folder with an index.html file in there so you can set your action to /thank-you/. Currently, our system isn’t parsing your form successfully as shown here: https://app.netlify.com/sites/alliance-investments/forms.

Regarding trailing slashes, just to reiterate the relevant doc here: https://docs.netlify.com/routing/redirects/redirect-options/#trailing-slash. Hopefully that helps you implement your site to match your needs.