You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 an Authorization header, overwriting any existing
// Authorization custom headers you have set using headers.
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"
}
})
The text was updated successfully, but these errors were encountered:
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.
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:
The text was updated successfully, but these errors were encountered: