I’ve looked at a few other posts and they are similar but I still cannot get mine to work. I have three other sites with forms on netlify I did in react/Gatsby and they work. This one is Vue3 and I get a 404 error after form submission. I don’t see the form submitted on my netlify dashboard.
The error is a 404: Page Not Found and its the same page as the contact page.
added a _redirect page to public folder which handled the site redirect breaking.
Tried: changed axios to fetch. Also used a raw netlify form without any ajax call. post URL changed to “/” as well.
site:
https://unrivaled-gelato-e3b6dd.netlify.app/contact
<form
id="myForm"
name="motive8contact"
method="post"
data-netlify="true"
data-netlify-honeypot="bot-field"
class="flex flex-wrap w-full"
@submit.prevent="handleSubmit">
>
form handler:
const handleSubmit = async (e: Event) => {
error.value = false;
const axiosConfig: AxiosRequestConfig = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
error.value = false;
await axios
.post(
location.href,
encode({
'form-name': e.target.getAttribute('name'),
...form.value,
}),
axiosConfig,
)
.then((response) => {
if (!error.value) doToast();
})
.catch((e: Error) => {
error.value = true;
doToast();
});
};
/**
*
* @param data
* encode the query params
*/
const encode = (data: FormInterface) => {
const formData = new FormData();
for (const key of Object.keys(data)) {
formData.append(key, data[key as keyof FormInterface]);
}
return formData;
};