4

I have this POST request with axios in React :

postRunSimulation(simulationId) {
  var requestAnalysis = `${configFile.web.backend}analysis/${simulationId}/run`;
  return axios.post(requestAnalysis)
  .then(function (response) {
    return response.headers;
  }, function(error) {
    throw new Error('An error occurred : ' + error.status + ' - ' + error.statusText);
  });
},

The object I get in return has a headers property but it's empty. If I make the same call with Postman, I get the headers. What am I doing wrong ?

Clafouti
  • 4,035
  • 5
  • 30
  • 38

1 Answers1

6

If your back-end is running on a different host or port than the web app, the browser can only access the following 6 response headers by default: Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, and Pragma (see also this answer). If the server does not return any of them, the headers will be empty.

Community
  • 1
  • 1
Nick Uraltsev
  • 24,607
  • 4
  • 25
  • 14