INTEGRITY Cloudflare Docs

API reference

The following methods can be used to configure your Pages Function.

Methods

onRequests

The onRequest method will be called unless a more specific onRequestVerb method is exported. For example, if both onRequest and onRequestGet are exported, only onRequestGet will be called for GET requests.

env.ASSETS.fetch()

The env.ASSETS.fetch() function allows you to fetch a static asset from your Pages project.

You can pass a Request object, URL string, or URL object to env.ASSETS.fetch() function. The URL must be to the pretty path, not directly to the asset. For example, if you had the path /users/index.html, you will request /users/ instead of /users/index.html. This method call will run the header and redirect rules, modifying the response that is returned.

Types

EventContext

The following are the properties on the context object which are passed through on the onRequest methods:

EnvWithFetch

Holds the environment variables, secrets, and bindings for a Function. This also holds the ASSETS binding which is how you can fallback to the asset-serving behavior.