How to send HTTP Basic auth without the login prompt
To open a staging site protected by HTTP Basic authentication without the browser's username and password dialog, send the credentials yourself in an Authorization header. Encode user:pass as base64 (printf 'user:pass' | base64 gives dXNlcjpwYXNz), then in HeaderDial add the request header Authorization with the value Basic dXNlcjpwYXNz, limited to the staging host. This works in Chrome, Edge or Firefox. Base64 is an encoding, not encryption, so only do this over HTTPS.
Why the prompt appears and how the header avoids it
A server using Basic authentication answers an unauthenticated request with 401 Unauthorized and a header like WWW-Authenticate: Basic realm="Staging". The browser reacts by showing its login dialog, then repeats the request with Authorization: Basic <base64 of username:password>. The browser remembers what you typed only for the current session, so the dialog comes back after a restart, in a private window and on every new test profile.
If the very first request already carries a valid Authorization header, the server never sends the 401 and the browser never asks. We checked this in Chrome 159 and Firefox 158 with HeaderDial 0.1.0, against a test server that returns 401 for any request without the right header: with the header set, the protected page loaded directly.
Compute the header value
Join the username and password with a colon and base64-encode the result. In a terminal:
printf 'user:pass' | base64
# dXNlcjpwYXNz
# if the password contains a % sign, pass it as an argument instead
printf '%s' 'user:p%ss' | base64
Avoid echo 'user:pass' | base64: echo adds a newline, which gets encoded too (dXNlcjpwYXNzCg==) and the server rejects it. In the browser's DevTools console:
btoa('user:pass') // "dXNlcjpwYXNz"
// btoa only accepts Latin-1 text; for other characters encode as UTF-8 first
btoa(String.fromCharCode(...new TextEncoder().encode('jürgen:pass')))
The username cannot contain a colon, because the first colon separates it from the password. The password can contain colons. To check a value you were given, decode it with printf 'dXNlcjpwYXNz' | base64 -d.
Steps
- Click the HeaderDial icon to open the popup. If the site-access banner appears, choose Allow on all sites or Only <current host>.
- Click + Request header, type
Authorizationas the name andBasic dXNlcjpwYXNzas the value: the wordBasic, one space, then your encoded string. Leave the operation on set. - Open Where it applies, click + Only on…, choose Domain and enter the staging host, for example
staging.example.com. - Optionally pick 8 hours or 1 day in the expiry select. The row counts down and the header switches itself off when the time is up.
- Open the staging site. No dialog should appear. If it still does, the encoded value is wrong or the filter does not match the host.
When the site uses Authorization itself
set replaces any Authorization header a request would have carried. If the staging app's own JavaScript sends Authorization: Bearer … to an API on the same host, your Basic value overwrites it and API calls fail. Add a + Never on… filter with type URL pattern for the API path, such as ||staging.example.com/api/, so those requests keep their own token. For Bearer tokens themselves, see how to add an Authorization header.
The curl equivalent
# let curl build the header
curl -u user:pass https://staging.example.com/
# or send it yourself
curl -H "Authorization: Basic dXNlcjpwYXNz" https://staging.example.com/
Security caveats
- Scope it to one domain. Without an Only on filter the header goes with every request to every site, including third-party scripts, fonts and analytics hosts, and they all receive your staging password.
- Use the timer. An expiry means you don't keep sending credentials weeks after the project ends. To stop everything at once, switch HeaderDial to Paused.
- Exports contain the password. Export all and Export this profile write header values into the file. When you use Share as link…, tick Leave header values empty so colleagues get the setup without your credentials.
- Prefer per-person accounts. If the staging server supports several users, give each tester their own password so one can be revoked without changing everyone's.
- Not in the URL.
https://user:pass@staging.example.com/puts the password into history and logs, and Chrome blocks subresource requests that carry credentials in the URL, so pages often break.
Pitfalls
- Credentials you already typed. After you log in through the dialog, the browser keeps sending those credentials for the rest of the session, and your header replaces them. To be sure the header alone gets you in, test in a private window with HeaderDial allowed there.
- Two profiles, one header. If two active profiles set Authorization, the leftmost chip wins. Reorder with Move left (higher priority) in the ⋯ menu.
- Redirects to another host. If staging redirects to a login or asset host with its own Basic auth, add that host to the filter, or if it needs different credentials, put them in a second profile with its own filter.
Add to ChromeFirefox: coming soon