Framework guides
Nuxt
The Vue guide, with the endpoint kept out of the client bundle.
The client-side approach from the Vue guide works unchanged. What Nuxt adds is the option of posting from the server, so the endpoint never reaches the browser:
server/api/contact.post.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const res = await $fetch("https://submit.formemailapi.com/YOUR_FORM_ID", {
method: "POST",
headers: { Accept: "application/json" },
body,
});
return res;
});Worth being clear about what this buys you: the endpoint is public either way. Server-side posting hides it from casual view and lets you add your own rate limiting, but it is not what keeps your form safe — your spam settings are.