1

I am using React + Redux on the front end and Spring for the backend. The reponse header contains Authorization header when viewed on browser and in postman but not when trying to access in javascript. I have added the photos showing response headers in network tab and on console tab. And also i am using axios for the request.

enter image description here

enter image description here

auth.js

...
export const authInit = (data) => {
    return dispatch => {
        dispatch(authInitStart());
        axios.post('/login', data)
            .then(response => {
                if(response.status === 200){

                    const param = {
                        'Authorization': response.headers.Authorization
                    };
                    console.log("Authorization----" + JSON.stringify(response));
                    console.log("Param----" + JSON.stringify(param));
                    localStorage.setItem('Authorization', param['Authorization']);
                    dispatch(authInitSuccess(param['Authorization']));

                }else{
                    dispatch(authInitFail('Request failed'));
                }
            }).catch(err => {
                dispatch(authInitFail('Network error'));
            });

    };
};
...

param object is empty here

What can be the issue?

Ujjwal Mishra
  • 177
  • 1
  • 8

1 Answers1

1

Access-Control-Expose-Headers: Authorization

response.headers.get('Authorization')

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

ikuner
  • 21
  • 2