Netlify function to Cloudflare Pages function

Is there an equivalent function in Cloudflare Pages as Netlify function
event.queryStringParameters.query and event.queryStringParameters.page
Found some reference but is for Cloudflare Workers.

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest (request) {
  const { search, pathname } = new URL(request.url)

}

Thanks in advance.

request is available in Pages Functions too, so you can still do things like const url = new URL(request.url). You’ll then be able to hit url.searchParams.get('page'), etc. Workers and Pages follow web standards closely, so the usual best place for technical documentation is something like MDN.

Example:

export async function onRequestGet(context) {
	const url = new URL(context.request.url);
	const page = url.searchParams.get('page');
	// etc.
	return new Response("Hello, world!");
}

For more info:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.