Code bundle format

To create the EdgeWorkers bundle, you need a JavaScript source file called main.js that contains event handler definitions for when to execute the code:

  • onClientRequest. This event happens for every request as the request is received, before checking if a response is available in cache.

  • onOriginRequest. This event happens just before sending the request to the origin.

  • onOriginResponse. This event happens as the origin response is created.

  • onClientResponse. This event happens for every request just before the client response is sent.

  • responseProvider. This event happens if the response is not already found in cache. You can use responseProvider to generate dynamic responses from various content and API sources.

You also need to create a manifest file called bundle.json that includes meta information as described in the table below.

NameTypeDescriptionRequired
edgeworker-versionStringUnique identifier for the EdgeWorkers version.‚úď
bundle-versionIntegerBundle format version.‚úó
api-versionStringVersion of JavaScript API when the EdgeWorkers code was created.‚úó
descriptionStringPhrase describing the EdgeWorkers script function.‚úó
miscObjectInformation you can include in the manifest to identify the EdgeWorkers function.‚úó

ūüďė

Limit edgeworker-version characters to alphanumeric, underscore, dash, dot, and tilde.

{
   "edgeworker-version":"4.22.3",
   "bundle-version":1,
   "api-version":"0.3",
   "description":"Language Redirect",
   "misc":{
      "author":"jsmith",
      "git-commit":"4ce52c8ff4fdd1771e5347297ea5691b55c4f6ed",
      "updated":"2027-09-23"
   }
}

Did this page help you?