Cancel Request Rule is a feature used to block network requests, allowing users to avoid distractions or test specific error scenarios effectively. This guide explains how to configure and utilize the Cancel Request Rule in your workflow.
Why Use Cancel Request Rule?
-
Blocking Distracting Websites: Leverage the Cancel Rule to block access to websites such as YouTube, Twitter, or Facebook to stay focused. Set the source condition to match the URLs of these websites and enable the rule.
-
Testing Error Scenarios: Simulate real-world application behaviors when resources are unavailable. For example, block a specific non-critical API request and observe how your application handles the missing resource.
How to Configure Cancel Rule
Open HTTP Rules and Create a New Rule
Navigate to the HTTP Rules section in your application and click on the + New Rule
button. From the available options, select Cancel Rule
to begin configuration.
Name and Describe Your Rule
Provide a descriptive name and an optional description for your Cancel Rule. This helps keep your rules organized and ensures clarity when managing multiple rules.
Define the Source Condition
Define where the rule should be applied by specifying criteria such as URL, Host, or Path. You can choose from options like Regex, Contains, Wildcard, or Equals, or use Advance Filters for more precise conditions.
For more details on source conditions, read this guide .
Let’s try to block product listing API call on https://www.requestly-playground.com/
Save and Activate the Rule
Once you have configured the conditions and filters, save the rule and toggle it on to activate. This ensures that the rule applies immediately to the specified requests.
Test the Rule
To ensure the rule is working correctly, click the Test
button and enter the URL of the page where the matching URL is called. This will open the webpage in a new tab, with a widget showing the status of applied rules.
There are multiple ways to validate if a rule is applied or not, learn more about how to validate rule execution.
On loading the https://www.requestly-playground.com/
website, it shows network error. A small widget on the page confirms that the Rule is applied. You can click on View Results button to view the result details.