[]previous and next page

createFetch

Wraps a handler as the { fetch(request, env, ctx) } module that Workers, Vercel and Netlify expect.

Wraps a handler as the { fetch(request, env, ctx) } module that Workers, Vercel and Netlify expect. The result is what a generated entry exports as its default.

Import#

ts
import { createFetch } from "@shadow-js/dusk/server";

Signature#

ts
function createFetch(handler: Handler, options: CreateFetchOptions = {}): FetchModule

Parameters#

Name Description
handler The handler from the server bundle.
options See CreateFetchOptions.

Returns#

The module.

Examples#

ts
export default createFetch(handler, { clientAddressHeader: "cf-connecting-ip" });