Framework guides
Nuxt
The Vue guide, with the key 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 key never reaches the browser:
server/api/contact.post.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const res = await $fetch("https://api.formpost.ai/submit", {
method: "POST",
headers: { Accept: "application/json" },
body: { ...body, access_key: process.env.CONTACT_ACCESS_KEY },
});
return res;
});Worth being clear about what this buys you: the key 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.