Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 3.03 KB

File metadata and controls

82 lines (57 loc) · 3.03 KB
title Quickstart
description Create and deploy your first Edge Script in minutes.
Login to [bunny.net dashboard](https://dash.bunny.net/auth/login?pk_buttonlocation=menu), then navigate to **Edge Platform** > **Scripting** and click **Add Script**.
<Frame>
  ![](/images/docs/0b5bff4662563e07b358a70392b77a8be85f58aa8e1cd21968b2dfef2f88b34e-image.png)
</Frame>
Provide a name for your script and select a script type:
<Tabs>
  <Tab title="Standalone">
    Select **Standalone** type and then **Default standalone** template.

    <Frame>
      ![](/images/docs/68f18ff3816d5947d7acd499028840c65c3e6c7dc5461a8e81d1f8807cc3548e-image.png)
    </Frame>

    Standalone scripts handle HTTP requests directly at the edge, without an origin server behind them. Use them for REST APIs, UI applications, and data processing.

    [Learn more about standalone scripts](/scripting/standalone/overview)
  </Tab>
  <Tab title="Middleware">
    Select **Middleware** type and then **Default middleware** template.

    Middleware scripts intercept and modify requests and responses as they flow through the CDN. Use them for authentication, header manipulation, and content transformation.

    [Learn more about middleware scripts](/scripting/middleware/overview)
  </Tab>
</Tabs>

Click **Add script**.
A pull zone is created for your script, so it is reachable from the outside through a unique URL. The script starts with a placeholder function that returns "Hello from" when you open that URL.
<Frame>
  ![](/images/docs/da2454f3d77252f3af19246fb567d36fcd0d40a767a564e238f3f481d3f4fcb5-image.png)
</Frame>

The bottom left panel is a preview pane where you can enter a URL and run the script currently open in the editor. Running it here doesn't change the deployed script, so you can test your code before publishing it.

<Frame>
  ![](/images/docs/23d1b7ac94614fa713ed6fb811bc5284d46539c1c2b8b0019d7ca6a344c9f7c0-image.png)
</Frame>

On the bottom right, the dashboard includes a logs pane. This pane captures and displays output from any `console.log` calls made by the script when it is run in the preview pane.

<Frame>
  ![](/images/docs/d5c773703340b197b87dbc664e48ae7fc0eae31d410d70ad2fca4acbb07994da-image.png)
</Frame>

Use it to trace what the script did on the last run and to confirm it behaved the way you expected.
Replace the placeholder with your own code, then open the script URL to check that your changes work. When you are happy with your script, click **Save** and **Publish**.
<Frame>
  ![](/images/docs/a3a37ccbb4b2fbbad74ad195292713e3875f727a99bb2bba411cc3e7c11e977a-image.png)
</Frame>

Published changes take effect immediately.