diff --git a/src/content/docs/rules/snippets/create-dashboard.mdx b/src/content/docs/rules/snippets/create-dashboard.mdx index b8750d95ad7b16..809b3a19541e46 100644 --- a/src/content/docs/rules/snippets/create-dashboard.mdx +++ b/src/content/docs/rules/snippets/create-dashboard.mdx @@ -13,20 +13,24 @@ import { Render } from "~/components"; 1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website. -2. Go to **Rules** > **Snippets**, and select **Create a Snippet**. +2. Go to **Rules** > **Snippets**. -3. In **Snippet name**, enter a descriptive name for the snippet. You cannot change the name after creating the snippet. +3. (Optional) If you have not created any snippets yet, select one of the snippet templates that addresses a common use case. Then, review and adjust the proposed snippet code. -4. Enter the snippet's JavaScript code in the code editor. You can test how your snippet will handle incoming requests using the **HTTP** and **Preview** tabs. + To start from scratch, select **Create Snippet**. -5. Select **Snippet rule** to configure when the snippet will run. +4. In **Snippet name**, enter a descriptive name for the snippet. You cannot change the name after creating the snippet. -6. Under **Run this Snippet if incoming requests match**, select if you wish to run the snippet only for requests that match a custom filter expression or for all incoming requests. +5. Enter the snippet's JavaScript code in the code editor. You can test how your snippet will handle incoming requests using the **HTTP** and **Preview** tabs. -7. (Optional) To define a custom expression, use the Expression Builder (specifying one or more values for **Field**, **Operator**, and **Value**) or manually enter an expression using the Expression Editor. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/). +6. Select **Snippet rule** to configure when the snippet will run. -8. Select **Done**. +7. Under **Run this Snippet if incoming requests match**, select if you wish to run the snippet only for requests that match a custom filter expression or for all incoming requests. -9. To deploy your snippet, select **Deploy**. If you are not ready to deploy your snippet, open the dropdown next to **Deploy** and select **Save as Draft**. +8. (Optional) To define a custom expression, use the Expression Builder (specifying one or more values for **Field**, **Operator**, and **Value**) or manually enter an expression using the Expression Editor. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/). - +9. Select **Done**. + +10. To deploy your snippet, select **Deploy**. If you are not ready to deploy your snippet, open the dropdown next to **Deploy** and select **Save as Draft**. + + diff --git a/src/content/docs/rules/snippets/index.mdx b/src/content/docs/rules/snippets/index.mdx index a7ba864ae60f6e..a740b47f1cef88 100644 --- a/src/content/docs/rules/snippets/index.mdx +++ b/src/content/docs/rules/snippets/index.mdx @@ -24,12 +24,16 @@ For code samples addressing common use cases, please refer to the [Examples](/ru ## Snippets elements -To create and deploy a Snippet, you need to define the following elements: +To create and deploy a snippet, you need to define the following elements: - **Code snippet**: JavaScript code to be executed during the request-handling process. -- **Snippet rule**: A [filter expression](/ruleset-engine/rules-language/expressions/) that determines which requests the Snippet will be applied to. Each Snippet can only be associated with one Snippet Rule. +- **Snippet rule**: A [filter expression](/ruleset-engine/rules-language/expressions/) that determines which requests the Snippet will be applied to. Each snippet can only be associated with one snippet rule. -For more information, refer to the [How it works](/rules/snippets/how-it-works/) and [Create a snippet in the dashboard](/rules/snippets/create-dashboard/) sections. +For more information, refer to [How it works](/rules/snippets/how-it-works/) and [Create a snippet in the dashboard](/rules/snippets/create-dashboard/). + +:::note +If you have used the Cloudflare API to create a code snippet that is not associated with a snippet rule, the Cloudflare dashboard will show that code snippet in a separate tab called **Unused Snippets**. You can either edit the snippet code and associate it with a snippet rule, or delete the unused code snippet. +::: ## Templates @@ -41,9 +45,7 @@ For more information, refer to the [How it works](/rules/snippets/how-it-works/) -:::caution[Redirects will count as subrequests] Each subrequest in a redirect chain counts against the subrequest limit. This means that if a subrequest was redirected it would count as two subrequests. To avoid issues, ensure that you make a subrequest to the end location of the redirect chain. -::: ## Limits