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.

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.
invoke-for-edgeworker-clientsBooleanWhen set to true, it enables support for subWorkers. By default, this configuration setting is set to false.
levelTRACE, DEBUG, INFO, WARN, or ERRORThe default JavaScript logging level applied to the EdgeWorkers code bundle. You can use this parameter to override the default log level, ERROR.
schemaStringNot currently in use. Use v1 as a placeholder.
ds2idIntegerThe Data Stream 2 stream id to associate with the JavaScript logging data.
The stream needs to be active before you include it in the EdgeWorkers code bundle.
When you add the logging config setting to the bundle.json file, the ds2id is required.


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

   "description":"Language Redirect",