Matt
CDCloudflare Developers
•Created by Matt on 12/2/2024 in #pages-help
I'm struggling to use a page function (for a simple contact form) with Astro
I've been following https://developers.cloudflare.com/pages/functions/plugins/static-forms/, I've put code in functions/contact.js:
import staticFormsPlugin from "@cloudflare/pages-plugin-static-forms";
export const onRequest: PagesFunction = staticFormsPlugin({
respondWith: ({ formData, name }) => {
const email = formData.get("email");
return new Response(
Hello, ${email}! Thank you for submitting the ${name} form.
,
);
},
});
But it fails to recognise and deploy the function with Pages. Nor is there any mention of it in the routes (which are meant to be auto generated?). Not sure what I'm doing wrong, tbh.1 replies