-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Describe the bug
The ambiguity of the docs between instance based requests and plan requests can cause confusion with regards to (basic) auth property and the Authorization header. The docs do not differentiate between request configurations and instanced based requests.
//
auth
indicates that HTTP Basic auth should be used, and supplies credentials.
// This will set anAuthorization
header, overwriting any existing
//Authorization
custom headers you have set usingheaders
.
Is it expected for Requests made using a defined instance to no be able to override the authorization header directly if the instance has a basic auth configured?
To Reproduce
Steps to reproduce the behavior:
// Plain axios request documented to prioritized `auth` field
const getWithAuthAndAuthHeader = axios.get(
"http://example.com/",
{
auth: {
username: "username",
password: "secure password"
},
headers: { Authorization: "OVERWRITTEN AUTH HEADER"}
}
)
// An axios instance with basic auth pre-configured
const instance = axios.create({
baseURL: "http://example.com",
auth: {
username: "username",
password: "secure password"
},
})
// Uses the instance and does not warn that Authrization header will be ignored
const getWithAuthHeaderOverride = instance.get("/", {
headers: {
Authorization: "AMBIGUOUSLY OVERWRITTEN AUTH HEADER"
}
})
// Uses the instance and circumvents the configured basic auth configuration
const getWithAuthHeaderOverride = instance.get("/", {
auth: null, // explicitly bypass basic auth
headers: {
Authorization: "OVERWRITTEN AUTH HEADER"
}
})
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed