Jon Sud
Jon Sud

Reputation: 11641

Why axios doesn't have headers in the response?

I using axios in version: "^0.19.2".

I have weird case. axios doesn't have the headers for the request although I can see the header in network tab.

My website goes: https://myweb.com, and the api: https://api.myweb.com/api with cors.

enter image description here

ders

What can be the problem?

Upvotes: 2

Views: 699

Answers (1)

squareborg
squareborg

Reputation: 1621

Because CORS is being used here, you have to expose the header on the server sending the response

Unsure of your backend but in Laravel, for example, you would do it in cors.php

exposed_headers' => ['x-access-token'],

For NodeJS Express CORS middleware you can use CORS configuration:

exposedHeaders: ['x-access-token']

Access-Control-Expose-Headers

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Access-Control-Expose-Headers

Upvotes: 1

Related Questions