Senger CodeLab πŸš€

How to filter hide Pre-flight requests on my Dev Tools Network

September 29, 2026

πŸ“‚ Categories: Programming
How to filter hide Pre-flight requests on my Dev Tools Network

Debugging web applications often involves sifting through a deluge of network requests in your browser’s DevTools. Among these, Pre-flight requests, also known as OPTIONS requests, can clutter your network panel and make it harder to identify the actual data exchanges you’re interested in. These requests are part of the Cross-Origin Resource Sharing (CORS) mechanism, ensuring that a web page served from one domain can safely request resources from a different domain. While crucial for security, their presence can significantly hinder your debugging workflow. The goal of this article is to provide a comprehensive guide on how to filter (hide) Pre-flight requests on your DevTools Network panel, allowing you to focus on the essential data and improve your debugging efficiency. We’ll explore various methods, from simple filter settings to more advanced techniques, equipping you with the knowledge to streamline your development process and gain better insights into your application’s behavior. This will ultimately save you time and reduce frustration when diagnosing issues.

Understanding Pre-flight Requests and CORS

Before diving into the filtering techniques, it’s crucial to understand what Pre-flight requests are and why they exist. As part of the CORS protocol, browsers initiate an OPTIONS request before making the actual request to a different domain. This Pre-flight request checks if the server at the target domain allows the specific request method (e.g., POST, PUT, DELETE), headers, and other parameters. If the server responds with the appropriate CORS headers, indicating that the request is permitted, the browser proceeds with the actual request. If the server denies the Pre-flight request, the browser blocks the subsequent request to prevent potential security vulnerabilities. Understanding this process is essential for effective debugging and troubleshooting CORS-related issues.

The CORS mechanism is a cornerstone of modern web security. Without it, malicious websites could potentially make unauthorized requests on behalf of a user, leading to data breaches and other security risks. Pre-flight requests act as a safeguard, providing a way for servers to explicitly control which cross-origin requests are allowed. While they are vital for security, they are often irrelevant when debugging the core functionality of an application, leading developers to seek ways to hide them from the DevTools Network panel. Ignoring the security implications of CORS can leave your application vulnerable, so it’s best to understand this process thoroughly.

For example, imagine you’re building a web application that needs to fetch data from a third-party API. When your application sends a request to the API, the browser might first send an OPTIONS request to check if the API allows requests from your domain. Only if the API responds affirmatively will the actual data request be sent. While this is happening, the DevTools Network panel will display both the OPTIONS request and the subsequent data request, potentially cluttering your view. Properly filtering these Pre-flight requests allows you to focus on the actual data exchange and quickly identify any issues with the API integration. This example clearly shows the impact of CORS and the need for effective Pre-flight request filtering.

Basic Filtering Techniques in DevTools

The simplest way to filter Pre-flight requests in your DevTools Network panel is by using the built-in filter functionality. Most modern browsers offer a text-based filter that allows you to specify patterns to match against the request URLs or other properties. To hide OPTIONS requests, you can simply type “-method:OPTIONS” (without the quotes) into the filter box. This will exclude any requests with the HTTP method “OPTIONS” from the displayed list. Alternatively, you can use “method:!OPTIONS” which achieves the same result. This method is quick and easy, making it suitable for simple debugging scenarios.

Another useful filtering technique involves using the “has-response-header” filter. Pre-flight requests typically don’t have response headers, as their primary purpose is to negotiate the CORS policy. You can use the filter “has-response-header:false” to hide requests that don’t have any response headers, which will often include Pre-flight requests. This can be particularly helpful if your application makes a lot of cross-origin requests and you want to focus on the actual data responses. Combining multiple filters can further refine your view. For example, you could use “-method:OPTIONS -domain:example.com” to hide OPTIONS requests from a specific domain.

Here’s a summary of the basic filtering techniques:

  • -method:OPTIONS: Excludes requests with the OPTIONS method.
  • method:!OPTIONS: Also excludes requests with the OPTIONS method.
  • has-response-header:false: Hides requests without response headers (often including Pre-flight requests).

These basic techniques are effective for many debugging tasks, but they might not be sufficient for complex scenarios. For instance, if you need to filter based on more specific criteria or create more persistent filtering rules, you might need to explore more advanced techniques, such as using custom filters or browser extensions. These techniques can be especially useful when working with larger projects or teams.

Advanced Filtering Options and Custom Filters

Beyond the basic filtering options, DevTools offers more advanced features that allow for more precise and persistent filtering of network requests. One powerful technique is using regular expressions in the filter box. For example, if you want to filter out requests that contain “preflight” or “options” in their URL, you can use the regular expression filter “/(preflight|options)/i” (without the quotes). This gives you more flexibility in defining your filtering criteria and allows you to handle more complex scenarios. Regular expressions can be an incredibly powerful tool for mastering DevTools Network filtering.

Another advanced approach involves using browser extensions designed specifically for filtering network requests. These extensions often provide more sophisticated filtering options and allow you to create custom rules that persist across browser sessions. Some extensions even allow you to share your filtering rules with other developers on your team, ensuring consistency in debugging workflows. While these extensions might require a bit more setup, they can significantly improve your debugging efficiency in the long run.

Here’s an example of how you might use regular expressions to filter out Pre-flight requests:

  1. Open your browser’s DevTools (usually by pressing F12).
  2. Navigate to the “Network” tab.
  3. In the filter box, type “/OPTIONS/i” (without the quotes).
  4. This will hide all requests that contain “OPTIONS” (case-insensitive) in their URL.

Featured Snippet Optimized: For a quick way to hide Pre-flight requests in Chrome DevTools, simply type “-method:OPTIONS” into the filter bar at the top of the Network panel. This will exclude all OPTIONS requests, which are typically Pre-flight requests sent as part of the CORS protocol, providing a cleaner view of your application’s network activity. This simple trick can significantly improve your debugging efficiency.

Best Practices for Efficient Debugging

While filtering Pre-flight requests can significantly improve your debugging experience, it’s essential to follow some best practices to ensure you’re not missing important information. Always remember that Pre-flight requests are crucial for security, and hiding them completely might prevent you from identifying potential CORS-related issues. Instead of permanently hiding them, consider using filters that you can easily toggle on and off as needed.

It’s also important to understand the context of your debugging session. Are you primarily focused on data exchange, or are you investigating CORS-related errors? Depending on your goal, you might need to adjust your filtering criteria accordingly. For example, if you’re encountering CORS errors, you’ll need to temporarily disable your Pre-flight request filter to inspect the OPTIONS requests and their corresponding responses. By tailoring your debugging approach to the specific problem you’re trying to solve, you can ensure that you’re not overlooking critical information.

Here are some additional tips for efficient debugging:

  • Use the “Preserve log” option to prevent the Network panel from clearing when you navigate to a new page.
  • Use the “Disable cache” option to ensure you’re always fetching the latest version of your resources.
  • Use the “Throttling” option to simulate different network conditions and test your application’s performance.

FAQ: Filtering Pre-flight Requests

Why are Pre-flight requests showing up in my DevTools?
Pre-flight requests are part of the CORS (Cross-Origin Resource Sharing) mechanism and are sent by the browser before actual cross-origin requests to ensure the server allows the request.
Will filtering Pre-flight requests affect my application's functionality?
No, filtering Pre-flight requests in DevTools only affects what you see in the Network panel. It doesn't prevent the requests from being sent or received.
Can I permanently disable Pre-flight requests?
You cannot permanently disable Pre-flight requests through DevTools or browser settings. They are a security feature enforced by the browser.
What if I need to debug CORS issues?
Disable your Pre-flight request filters to inspect the OPTIONS requests and their responses. Look for missing or incorrect CORS headers in the server's response.
You've now gained a solid understanding of how to streamline your debugging process by effectively filtering out Pre-flight requests in your DevTools Network panel. By mastering these techniques, from basic filtering to advanced regular expressions and browser extensions, you can focus on the essential aspects of your application's network activity. Remember to consider the security implications of CORS and tailor your filtering approach to the specific debugging task at hand. Now that you're equipped with these skills, why not explore other DevTools features to further enhance your debugging capabilities? Dive into analyzing performance metrics, inspecting network timings, or even simulating different network conditions. Continue to refine your skills, and you'll be well on your way to becoming a debugging master. Also, remember to check out this [guide for more advanced DevTools tips](https://courthousezoological.com/n7sqp6kh?key=e6dd02bc5dbf461b97a9da08df84d31c). For more information on CORS, you can visit [the W3C's CORS specification](https://www.w3.org/TR/cors/) or check out [PortSwigger's Web Security Academy](https://portswigger.net/web-security/cors) for in-depth security guidance. You can also consult [OWASP's Top Ten](https://owasp.org/www-project-top-ten/) to learn more about common web security vulnerabilities. **Question & Answer :** Normally both calls are shown, the pre-flight and the actual request. This is sometimes annoying. Is there a way to hide the pre-flights requests ?

Or is there a plugin to filter certain requests based on headers ?

The quickest way to do this is to filter on -method:OPTIONS.

enter image description here

Explanation: all pre-flight requests are via the HTTP OPTIONS method (opposed to POST or GET). This filter says “not method OPTIONS”.

Note the leading hyphen because if you forget it, you’ll only show pre-flight requests.