How Hostname Matching Works
Decipher matches hostnames using subdomain matching. When you add a hostname likevercel.app, it will match any URL whose host ends with
that value — for example my-app-git-feat-acme.vercel.app.
This means you only need one entry per hosting provider, not one per
preview URL.
Setting Up Custom Host Headers
- Go to Settings > Testing
- Under Custom Host Headers, click Add Hostname
- Enter the hostname to match (e.g.,
vercel.app) - Add one or more HTTP headers as key-value pairs
- Click Save
Vercel Example
Vercel’s Deployment Protection blocks unauthenticated access to preview deployments. You can bypass it by sending a secret header.Step 1 — Get your bypass secret
- Open your Vercel project’s Settings > Deployment Protection
- Under Protection Bypass for Automation, copy the secret value
Step 2 — Add the hostname and header in Decipher
- In Decipher, go to Settings > Testing and find Custom Host Headers
- Click Add Hostname and enter
vercel.app - Add a header:
- Key:
x-vercel-protection-bypass - Value: the secret you copied from Vercel
- Key:
- Click Save
Custom Script
Sometimes static HTTP headers aren’t enough — for example, when you need to compute an HMAC signature, attach a rotating token, or dynamically modify requests at runtime. Custom Script lets you write a JavaScript snippet that runs in the browser before any page scripts on every page load during a test.When It Runs
Whenever a test navigates to a URL whose host matches the configured hostname, the script is injected and executed before the page’s own scripts run. This happens on every navigation (initial load, client-side route change, or redirect) to the matching host.What It Has Access To
The script runs in the page’s browser context, so it has access to all standard browser APIs:windowanddocumentfetchandXMLHttpRequestlocalStorageandsessionStorage- Cookies via
document.cookie
Setting Up a Custom Script
- Go to Settings > Testing
- Under Custom Host Headers, click Add Hostname (or edit an existing one)
- Write your JavaScript in the Custom Script editor
- Click Save
Example — Injecting a Header into Every Fetch Request
Custom Script and HTTP headers can be used together on the same
hostname. HTTP headers are added to every outgoing request at the network
level, while the custom script runs in the page’s JavaScript context.