Skip to content

Commit 371cdac

Browse files
authored
[Updated]: clarify auth behavior with axios instances (#315)
- Add examples for overriding instance-level auth - Explain auth: null pattern to bypass basic auth - Clarify precedence of instance auth over request headers Resolves #221
1 parent bdc1b13 commit 371cdac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

posts/en/req_config.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ These are the available config options for making requests. Only the `url` is re
9797
// `Authorization` custom headers you have set using `headers`.
9898
// Please note that only HTTP Basic auth is configurable through this parameter.
9999
// For Bearer tokens and such, use `Authorization` custom headers instead.
100+
101+
// When using axios instances with pre-configured `auth`, you can override
102+
// or bypass the instance's basic auth configuration in individual requests:
103+
//
104+
// 1. Override with different credentials:
105+
// instance.get('/path', { auth: { username: 'other', password: 'pass' } })
106+
//
107+
// 2. Bypass basic auth and use a custom Authorization header:
108+
// instance.get('/path', { auth: null, headers: { Authorization: 'Bearer token' } })
109+
//
110+
// Note: If you don't set `auth: null`, the instance's pre-configured basic auth
111+
// will take precedence over any `Authorization` header you set in the request config.
112+
100113
auth: {
101114
username: 'janedoe',
102115
password: 's00pers3cret'

0 commit comments

Comments
 (0)