Test EdgeWorkers functions

In order to test your EdgeWorkers code in an isolated sandbox environment, you need to first create a sandbox and know the EdgeWorker ID. You also need to create a code bundle.

You can use Sandbox to test the EdgeWorkers functions locally and iterate before deploying them to the content delivery network.

📘

All actions in your Sandbox do not affect the EdgeWorkers environment.

If you don’t override the EdgeWorker bundle by running the update-edgeworker command for your sandbox, the Sandbox environment uses the one that is active in the EdgeWorkers staging environment.

  1. Create a sandbox based on the property with the EdgeWorker setup.

  2. Use curl or a browser to test the functionality.

    • Curl: Run this command curl --header 'Host: www.example.com' http://127.0.0.1:9550/
    • Browser: Open your /etc/hosts file and point the hostname associated with the property configuration to 127.0.0.1, then enter http://<your-hostname>:9550 in your browser.
  3. Run this command every time you want to update your EdgeWorkers code.

    akamai sandbox update-edgeworker <edgeworker-id> <edgeworker-tarball>
    

    Your sandbox will reflect the changes after a few seconds.

  4. Run this command to delete the modified EdgeWorkers code from your sandbox.

    akamai sandbox delete-edgeworker <edgeworker-id>
    

    Your sandbox will reflect the changes after about 10 seconds. After deleting the bundle from your sandbox, it starts using the EdgeWorker ID version that is active in the EdgeWorkers staging environment.

📘

Refer to the EdgeWorkers User Guide for more information on deploying JavaScript functions at the edge.