createProxy
createProxy(
input):object
Creates the site proxy. Its fetch forwards everything under
MOUNT_PREFIX to the tenant, the injected script at
SCRIPT_PATH included, and passes other requests to the site’s own
server. For a GET answered 200 with HTML, it reads the content facts from
the page’s <head>, asks decide, and rewrites the page in one pass while the
rest of it streams through. When decide answers, the page is sent with
cache-control: private, no-store. A page’s ?edgekitPreview= sets the
edgekit_preview cookie, and off clears it, on every HTML page it serves,
decided or not; such a page is private, no-store too.
const proxy = createProxy({ env, adapter });export default { fetch: (request) => proxy.fetch(request) };Build it once and reuse it: settings are read at construction, and their warnings are reported once rather than on every request. With a required setting missing, it passes every request through unmodified.
Parameters
Section titled “Parameters”adapter
Section titled “adapter”Record<string, unknown>
Returns
Section titled “Returns”object
fetch: (
request) =>Promise<Response>
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>