DevHeaders
← Back to guides
http-headersstagingfeature-flagsapi-testingdeveloper-tools

How to Simulate Staging or Production Environments with Custom Request Headers

Switching between staging and production usually means editing a .env file, restarting a dev server, or juggling two sets of API keys in a notes app. If your backend supports header-based environment routing — and a lot of API gateways do — you can skip all of that and switch environments by clicking a tab in your browser instead.

Why Header-Based Environment Switching Works

Many API gateways, reverse proxies, and feature flag systems don’t route purely on domain — they also inspect request headers before deciding where a request goes or how it behaves:

If your infrastructure already supports this — check with your backend or platform team if you’re not sure — you don’t need separate builds, separate .env files, or a VPN switch to test against a different environment. You need the right header, present or absent, on the request.

Common Headers Used to Simulate Environments

Header Purpose Example value
X-Environment Tells the gateway which backend to route to staging, production
X-Api-Key / Authorization Environment-specific credentials sk_staging_abc123
X-Api-Version Routes to a specific API version or cluster v2, v3-beta
X-Feature-<name> Forces a feature flag on for this request true
X-Canary Routes to the newest deployment true
X-Region Simulates a request from a specific region eu-west, us-east

None of these are standard HTTP headers — they only do something if your backend, gateway, or feature flag system is explicitly built to read them. Check your platform’s docs (or ask whoever owns the API gateway) before assuming header-based switching will work out of the box.

Setting Up Environment Profiles in DevHeaders

DevHeaders organizes headers into named profiles, which maps cleanly onto “one profile per environment.”

Step 1: Create a Profile per Environment

Open the DevHeaders popup and use the + tab to create a profile for each environment you test against — e.g. “Staging” and “Production.”

Step 2: Add the Headers Each Environment Needs

In the “Staging” profile:

X-Environment: staging
X-Api-Key: sk_staging_abc123

In the “Production” profile:

X-Environment: production
X-Api-Key: sk_prod_xyz789

Step 3: Switch by Clicking the Profile Tab

Only the active profile’s enabled headers go out. To move from staging to production, click the “Production” tab — nothing to edit, delete, or re-type.

Step 4: Use the Master Switch as a Safety Net

Flip the master switch off when you’re not actively testing. Since DevHeaders doesn’t scope headers by URL, an active profile’s headers go out on every site you visit, not just your API’s domain — you don’t want a production API key firing on unrelated tabs.

Example: Simulating a Feature Flag Rollout

Beyond environment switching, the same mechanism works for previewing an unreleased feature before it’s live for real users:

Profile: Feature Preview
Header: X-Feature-New-Dashboard
Value: true

Enable the profile, load your app, and you’re looking at the new dashboard — without changing the flag’s default for anyone else. Disable the profile (or the header) and you’re back to current behavior.

Gotchas to Watch For

Only one profile is active at a time. DevHeaders doesn’t let you run staging and production simultaneously in the same browser. If you need to compare both side-by-side, use two separate Chrome browser profiles (Chrome’s own multi-profile feature, not DevHeaders’ profiles) with a different DevHeaders profile active in each.

This only works if your backend actually checks the header. Sending X-Environment: staging does nothing unless something downstream is written to branch on it. If nothing changes when you toggle the header, it isn’t wired up server-side yet — that’s an infrastructure question, not an extension question.

No URL scoping. Because DevHeaders applies enabled headers to every outgoing request rather than filtering by domain, be deliberate about which profile is active — especially one holding a production key — and turn it off when you’re done.

Frequently Asked Questions

Can I test staging and production at the same time in one browser window? Not with one DevHeaders profile — only one profile is active at a time. Use separate Chrome browser profiles if you need true side-by-side comparison.

Does this replace a real staging environment? No — it’s a way to reach different backend behavior from your existing browser session via headers your infrastructure already understands. You still need a backend that’s built to respond to the header.

Can I share environment profiles with my team? Yes — DevHeaders supports profile export/import, so you can hand teammates a ready-made “Staging” or “Production” profile instead of everyone typing in their own API keys.

Is this safe for production credentials? Treat it the same as any place you’d store a token: don’t leave a production-keyed profile active by default, and use the master switch to disable everything when you’re not actively testing.


DevHeaders is a free Chrome extension for managing HTTP request headers. Install it from the Chrome Web Store and switch environments by clicking a tab instead of editing a config file.