HardAtWork
04/28/2023, 4:13 PMts
export const onRequest: PagesFunction = async ({ request, next }) => {
const response = await next();
// Clone the response so that it's no longer immutable
const newResponse = new Response(response.body, response);
// Add a custom header with a value
newResponse.headers.append(
"x-workers-hello",
"Hello from Cloudflare Workers"
);
return newResponse;
}
Lloyd
04/28/2023, 4:14 PMLloyd
04/28/2023, 4:14 PMHardAtWork
04/28/2023, 4:15 PMPagesFunction
too.Lloyd
04/28/2023, 4:15 PMSkye
04/28/2023, 4:16 PMSkye
04/28/2023, 4:16 PMHardAtWork
04/28/2023, 4:17 PMLloyd
04/28/2023, 4:17 PMChaika
04/28/2023, 4:18 PMWalshy | Pages
04/28/2023, 4:18 PMLloyd
04/28/2023, 4:18 PMHardAtWork
04/28/2023, 4:18 PMSkye
04/28/2023, 4:18 PMLloyd
04/28/2023, 4:20 PMHardAtWork
04/28/2023, 4:20 PMnext()
means fetch()
the next Function or static asset. So if you need the Response at the beginning of the Function, you call next()
first. If you want it as a fallback, you call next()
last.HardAtWork
04/28/2023, 4:20 PMHardAtWork
04/28/2023, 4:21 PMfetch(request)
Walshy | Pages
04/28/2023, 4:30 PMWalshy | Pages
04/28/2023, 4:30 PMspacey
04/28/2023, 4:38 PMspacey
04/28/2023, 5:28 PMsettings/functions
web ui. do i have to manually add these bindings i through wrangler.toml configured it automatically?spacey
04/28/2023, 6:07 PMhono
and workers-qb
it add a user row to id and sends the same data to queues. this works in dev (minus queues) however when deployed i'm getting a 500 with RangeError: Maximum call stack size exceeded
spacey
04/28/2023, 6:21 PMzszszsz
04/28/2023, 9:48 PMzszszsz
04/28/2023, 9:49 PMLloyd
04/28/2023, 9:55 PMspacey
04/28/2023, 10:07 PMspacey
04/28/2023, 10:09 PM