Hi there,
Hoping someone can help with the following issue we have seen introduced to our Netlify form usage.
From having our 1 contact form working, the past week has seen it fail on submissions with a 405: ‘Method not allowed’ response on the result of a POST request over fetch.
Please see for yourself on https://www.rowsehoney.co.uk/contact
The deploy log seems to show that it still detects the form.
We use next.js and can confirm the form attribute of data-netlify=“contact” remains in place, and the POST via a fetch remains unchanged from when it was working.
Our fetch request can be simplified to the following:
Adding a simple clone of just the form and fields in html and adding that file to the public folder that gets statically served, followed by referencing this url in the fetch did the trick.
I now understand why ISR won’t work without a solution like this as there is no file in the public directory on deploy to map an action url to, as such files only get created and served via the next.js express service, rather than statically built.
Thanks @hrishikesh
@coelmay - I did need the .html in the path, because if not nextjs thinks it’s a page and it didn’t work. Thank you for confirming so quickly, though! Saved me.
I am not sure what gave you the idea that we’re asking you to send a GET request. You indeed have to send a POST request, except the target URL to which you send a request should be a static file without any redirects or server-side rendering in place.
So, if you’re using ISR on your home page, this would not work if you do something like:
fetch("/", {})
You need to create a static file and post to that. It could also be your favicon like:
fetch("/favicon.ico", {})
and it would still work. The only requirement is that the file should be static, and non-redirected.
Thank you so much for taking the time to answer. The form is now working with ISR
What made me confused is when @AlfieB was talking about the form.html so in my head, I was thinking: how is a post request made on index.js is going to reach a form on another page?
I was able to understand that the file doesn’t matter when you said to post to favicon.ico
Still, making a POST request to a favicon icon sounds mind-blowing to me!