Creating a form in Vue.JS and connecting with Netlify's form submission handler. Can't redirect to a custom thank you page. Netlify's default thank you page always appears.
Searched for awhile on doc and forums but to no avail.
I have the routes setup correctly to handle the new page /success. Below you can see I have added an action to the form which should be in the correct format.
I think the problem is either something to do with Vue.JS routing or Netlify's way of identifying if /success is an active component/page. As in the netlify docs it says if the action path is not valid then it will automatically default back to netlify's thank you page.
https://github.com/DanielGibsonOrchid/freightlegend
https://freightlegend.netlify.com/
<form
action="/success"
class="get-started-form"
name="get-started"
method="post"
data-netlify="true"
data-netlify-honeypot="bot-field"
>
<input type="hidden" name="bot-field" />
<input type="hidden" name="form-name" value="get-started" />
<div class="form-content flex">
<input type="text" name="name" placeholder="Your name" class="input-main" required />
<input type="email" name="email" placeholder="Your email" class="input-main input-margin" required />
<div class="select-div">
<select name="country" class="input-main">
<option value="New Zealand">New Zealand</option>
<option value="Australia">Australia</option>
<option value="USA">USA</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<input type="submit" class="btn-main" />
<!-- <button type="submit" class="btn-main">Submit Query</button> -->
</form>
public/_redirects
/locale.json /locales/us.json 302 Country=us
/locale.json /locales/au.json 302 Country=au
/locale.json /locales/nz.json 302 Country=nz
/* /index.html 200
Looks like you've done just about everything possible. At this stage, I'd have to guess that using a custom success page with a SPA is not something Netlify handles.
I would instead use an AJAX form submission.
For example
<form @submit.prevent="handleFormSubmit" ...>
methods: {
async handleFormSubmit ($event) {
const form = $event.target
const body = new URLSearchParams(new FormData(form))
try {
const res = await fetch(form.action, { method: 'POST', body })
if (res.ok) {
this.$router.push({ name: 'thanks' })
} else {
throw res
}
} catch (err) {
console.error(err)
// you don't have an error page but maybe you should add one
}
}
}