🎉 Requestly joins BrowserStack to build the future of application testing. Read more

Using Requestly to Toggle Feature Flags

Kanishk Rawat
Learn how to test feature flags easily with Requestly by modifying headers and cookies, no backend changes needed for faster, safer releases.
Feature flags (also known as feature toggles, release switches, or experiments) are a core part of modern software development. They allow teams to enable or disable certain pieces of functionality without deploying new code. This article explains what feature flags are, why they’re valuable, and how you can test them effectively using Requestly.

What Are Feature Flags?

A feature flag is a conditional switch built into the codebase that controls whether a particular piece of code runs. If the flag is turned on, the feature is activated. If the flag is turned off, the code is skipped. This gives teams the ability to separate deployment (shipping code) from release (making features available to users). You can push code to production but keep features hidden until they are fully ready or selectively activate them for specific groups of users.

Why Use Feature Flags?

Feature flags offer several key advantages during development:
  • Controlled Rollouts: Gradually release a feature to a small user segment before expanding access more broadly.
  • A/B Testing and Experiments: Run experiments by exposing different users to different versions of a feature and measure performance or engagement.
  • Continuous Deployment: Deploy code regularly without exposing unfinished features, allowing faster iteration and safer releases.
  • Quick Hotfixes: Instantly disable a feature if it’s causing issues, without needing to roll back the entire application.
  • Personalized User Experiences: Target features to specific users, regions, or environments for customized experiences.
Overall, feature flags improve flexibility, reduce release risks, and enable faster experimentation.

The Challenge of Testing Feature Flags

Once you introduce multiple flags into a system, it becomes important to test not just whether a feature works, but how combinations of flags behave together. For example, you might need to check:
  • How a page behaves with certain flags on or off
  • Whether specific users are seeing the right feature versions
  • How the app handles fallback states
Manually toggling these on the backend or setting up different environments can be time-consuming.

How Requestly Helps You Test Feature Flags

Requestly is a powerful tool that lets you modify HTTP requests and responses directly from your browser or desktop app. You can inject headers, change cookie values, redirect traffic, or modify responses, all without touching backend configurations.

This makes it especially useful for testing feature flags that are controlled by request headers or cookies.

How To Simulate Header-Based Feature Flag ?

Step 1: Open Requestly
Install the Requestly browser extension or open the desktop app.

Step 2: Create a Modify Header Rule
Set up a rule like this:

  • Rule Type: Modify HTTP Headers ( select request header )
  • URL Pattern: Match your app’s domain (for example, https://your-app.com/*)
  • Header Name: The feature flag header name (for example, X-Feature-Flag)
  • Header Value: The feature you want to enable (for example, FEATURE_FOO_BAR)

Step 3: Save and Enable the Rule
Once active, this will inject the feature flag header into your requests, allowing you to simulate the feature being turned on.

Step 4: Test Without the Feature Flag
To test the application without the feature flag, simply disable the rule or delete it and refresh the page.

What About Cookie-Based Feature Flags?

As of now, Requestly doesn’t have a dedicated rule type specifically for modifying cookies directly. However, you can still override or insert cookie values by following a simple workaround.

Check out this step-by-step guide on how to modify cookies using Requestly:
https://docs.requestly.com/guides/how-to-modify-cookies-using-requestly

This method works similarly to modifying headers but targets cookies instead, letting you manage cookie-based feature flags effectively.

Want to Learn More About HTTP Headers?

Written by
Kanishk Rawat
Kanishk Rawat, a tech enthusiast since childhood, has mastered programming through dedication. Whether solo or in a team, he thrives on challenges, crafting innovative solutions .

Related posts