Seems so. Annoying no one has responded to it! How are you dealing with it?
Seems so. Annoying no one has responded to it! How are you dealing with it?
/functions directory and placing scripts there: https://developers.cloudflare.com/pages/functions/get-started/, however I also noticed that Astro has this guide on endpoints: https://docs.astro.build/en/guides/endpoints/, and it seems this could also work? However, when using Cloudflare Pages for deployment, I am not sure which method is recommended. If i follow Astro's guide on endpoints, would these automatically be served by Pages in a similar way to the Functions? Anyone with experience with deploying Astro to Cloudflare Pages can shine some light on this?
ms. More CPU-heavy things will increase it (hashing passwords). This is not the same as the time a fetch request takes - a request might take 10 seconds but only use 1ms of CPU Time.
/functions/[[catchall]].js. This code logic works when deployed separately as a cf worker but not when translated to a cf pages function.env.ASSETS.fetch there instead which will try to request the site content 
// src/middleware.js
export async function onRequest({ request, locals }, next) {
// Check if the current request path matches the specific form action path
if (new URL(request.url).pathname === '/form-path' && request.method === 'POST') {
try {
// Process form data
const formData = await request.formData();
// Example of form data processing.
if(formData.get('name') !== "john") {
throw new Error("Name must be john!")
}
// After processing successfully, redirect to `/form-submitted`
return Response.redirect(new URL("/form-submitted", request.url), 302);
} catch (error) {
// If there's an error in processing, set `locals.formError`
// This can later be checked in the endpoint handling the form submission
locals.formError = error.message;
}
}
// If the path does not match, proceed with the normal request flow.
return next();
}/functions/[[catchall]].jsenv.ASSETS.fetchexport async function onRequest(context) {
const { request } = context;
let url = new URL(request.url);
// Set the hostname to the original site
url.hostname = "example.com";
let ogResponse = fetch(url, request);
// Now set the hostname to the Cloudflare Pages version
url.hostname = "test-branch.example.pages.dev";
const cfPagesResponse = await fetch(url, request);
// Return the Cloudflare Pages response if it's not a 404
if (cfPagesResponse.status !== 404) {
return cfPagesResponse;
}
// Otherwise, return the original site's response
return await ogResponse;
}