I have a form component where user fills out the inputs, hits send and then is redirected to the success page. But if anyone who would like to enter url manually like domain.com/success, he will see that page. How can I disable this? For example, if enters domain.com/success, then redirects to /home. Here is my code:
import React, { useState } from "react"
const ContactForm = () => {
const [formInput, setFormInput] = useState({
email: "",
message: "",
})
const onChange = e => {
setFormInput({
...formInput,
[e.target.name]: e.target.value,
})
}
return (
<section className="contact-form" id="contact">
<h1>Contact Us</h1>
<div className="container">
<form
method="post"
netlify-honeypot="bot-field"
data-netlify="true"
name="contact"
action="/success"
>
<input type="hidden" name="form-name" value="contact" />
<div className="form-group">
<div className="form-input">
<input
type="email"
className="form-control"
id="exampleFormControlInput1"
placeholder="Your email"
name="email"
required
value={formInput.name}
onChange={onChange}
></input>
</div>
</div>
<div className="form-group">
<div className="form-input">
<textarea
className="form-control"
id="exampleFormControlTextarea1"
rows="3"
placeholder="Your message"
name="message"
required
value={formInput.message}
onChange={onChange}
></textarea>
</div>
</div>
<button type="submit" className="button button--lg">
Send
</button>
</form>
</div>
</section>
)
}
export default ContactForm