'Axios Adding two of the same headers with different values

Axios is an NPM package that allows you to perform HTTP requests. I am trying to add two identical headers with different values to perform a pen-test on an API. When sending this request the response code is 200, although I only have one of the headers I passed to Axios.

!!~Disclaimer~!! This request is being performed on the websites origin IP address. (No WAF)

const { default: axios } = require('axios');

axios.get('http://example.com/api', {
 headers: {
    "X-Forwarded-For": "",
    "X-Forwarded-For": '127.0.0.1',
 }
}).then(res => {
    console.log(res);
});
  status: 200,
  statusText: 'OK',
  headers: {
    server: 'nginx',
    date: 'Fri, 25 Mar 2022 15:02:24 GMT',
    'content-type': 'application/json; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    vary: 'Accept-Encoding, Accept-Encoding',
    'x-ratelimit-limit': '12',
    'x-ratelimit-remaining': '11',
    'x-ratelimit-reset': '1648220552',
    'cache-control': 'public, max-age=60',
    etag: '"'
  },
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [Function: httpAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'X-Forwarded-For': '127.0.0.1',
      'X-Forwarded-Host': '127.0.0.1',
      'User-Agent': 'axios/0.26.1'
    },
    method: 'get',
    url: 'http://example.com/api/',
    data: undefined
  },


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source