Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers get lost when retrying #218

Open
maxharlow opened this issue Nov 11, 2022 · 2 comments
Open

Headers get lost when retrying #218

maxharlow opened this issue Nov 11, 2022 · 2 comments

Comments

@maxharlow
Copy link

Retried requests seem to lose the configured headers. For example this:

import Axios from 'axios'
import AxiosRetry from 'axios-retry'

AxiosRetry(Axios)

Axios.interceptors.request.use(config => {
    console.log(config.headers)
    return config
})

Axios({
    url: 'http://httpstat.us/500',
    headers: {
        authorization: 'Basic example'
    }
})

Produces this output:

AxiosHeaders {
  authorization: 'Basic example',
  [Symbol(defaults)]: { Accept: 'application/json, text/plain, */*' }
}
AxiosHeaders {
  '[object Object]': undefined,
  [Symbol(defaults)]: { '0': [Function: get] }
}
node:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["0"]
    at ClientRequest.setHeader (node:_http_outgoing:606:3)
    at new ClientRequest (node:_http_client:275:14)
    at Object.request (node:http:96:10)
    at RedirectableRequest._performRequest (/Users/maxharlow/Desktop/node_modules/follow-redirects/index.js:284:24)
    at new RedirectableRequest (/Users/maxharlow/Desktop/node_modules/follow-redirects/index.js:66:8)
    at Object.request (/Users/maxharlow/Desktop/node_modules/follow-redirects/index.js:523:14)
    at dispatchHttpRequest (file:///Users/maxharlow/Desktop/node_modules/axios/lib/adapters/http.js:371:21)
    at new Promise (<anonymous>)
    at httpAdapter (file:///Users/maxharlow/Desktop/node_modules/axios/lib/adapters/http.js:105:10)
    at Axios.dispatchRequest (file:///Users/maxharlow/Desktop/node_modules/axios/lib/core/dispatchRequest.js:46:10) {
  code: 'ERR_INVALID_CHAR'
}

So you can see the authorisation header has been lost on the retried request, replaced with '[object Object]': undefined.

I'm using Axios v1.1.3 and Axios Retry v3.3.1.

@HpSurani1997
Copy link

I have also same issue with Axios v1.1.3. upgrade axios version to 1.2.0-alpha.1. it is work for me.

@efortes
Copy link

efortes commented Aug 18, 2023

I had 1.1.2 and had to upgrade to 1.4.0 to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants