Axios CORS unable to see any response header

Hi I have a frontend being served for testing from localhost making request to backend running at which is an Nginx server fronting a Django backend.

The client app code is:

const axiosApi = axios.create({
  baseURL: API_URL,
  withCredentials: true,

export async function post(url, data, config = {}) {
   return axiosApi
    .post(url, { }, {withCredentials: true})
    .then(response =>
    .then(response => {
        console.log("response is", response);
        console.log("WOW GOT", response.headers);
        console.log("CUSTOM", response.headers.get("Cache-Control"));


The request and response headers are as follows as seen from browser:

Request URL:
Request Method: POST
Status Code: 302 
Remote Address:
Referrer Policy: strict-origin-when-cross-origin

Response Headers:

access-control-allow-credentials: true
access-control-allow-origin: http://localhost:5173
access-control-expose-headers: accept, accept-encoding, authorization, content-type, dnt, origin, user-agent, x-csrftoken, x-requested-with, cache-control, pragma, Set-Cookie
content-length: 0
content-type: text/html; charset=utf-8
cross-origin-opener-policy: same-origin
date: Sun, 05 Feb 2023 01:21:28 GMT
location: /
referrer-policy: same-origin
server: nginx/1.21.6
set-cookie: csrftoken=zaBGdsPdVSEm1ZRvgNKuGxQcr2mRJvhh; expires=Sun, 04 Feb 2024 
 01:21:28 GMT; Max-Age=31449600; Path=/; SameSite=None; Secure
set-cookie: sessionid=z3gygehf6gcwuc5pdq2v8kzff61ipcss; expires=Sun, 19 Feb 2023 01:21:28 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=None; Secure
vary: Origin, Cookie
x-content-type-options: nosniff
x-frame-options: DENY

Request Headers

:method: POST
:path: /auth/login
:scheme: https
accept: application/json, text/plain, */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
content-length: 44
content-type: application/json
origin: http://localhost:5173
referer: http://localhost:5173/
sec-ch-ua: "Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: cross-site
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

In the console, I am trying to log the response headers when I get response:

  console.log("WOW GOT", response.headers); // prints WOW GOT undefined

Why is there no headers being avilable to axios client when I can see them in browser?

Back to Top