diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3477fdd --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +VITE_API_BASE_URL="http://localhost:3001/v4" \ No newline at end of file diff --git a/.gitignore b/.gitignore index a547bf3..438657a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +.env # Editor directories and files .vscode/* diff --git a/src/components/ContactForm.tsx b/src/components/ContactForm.tsx index e023781..100cc7a 100644 --- a/src/components/ContactForm.tsx +++ b/src/components/ContactForm.tsx @@ -22,7 +22,7 @@ export default function ContactForm() { } else { console.log("Form submitted") - fetch("https://api.alexav.gg/v4/contact", { + fetch(import.meta.env.VITE_API_BASE_URL + "/contact", { method: "post", headers: { 'content-type': 'application/json' @@ -32,7 +32,11 @@ export default function ContactForm() { if (res.ok) { setSuccess(true) } else { - setError("An error occurred while submitting your info.") + if (res.status === 429) { + setError("Too many tries! Try again later") + } else { + setError("An error occurred while submitting your info.") + } } }).catch((e) => { console.error(e) @@ -50,7 +54,7 @@ export default function ContactForm() { setTimeout(() => { setSuccess(false) }, 6000) - }) + }, [success]); return (