티스토리 뷰
axios를 통해서 response.headers를 읽던 중 content-disposition을 읽을 수 없을 때
const fileName = response.headers['content-disposition'].split("filename=")[1];
CORS인 경우 서버 단에서 아래와 같이 content-disposition을 노출시켜줘야함.
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION);
참고
https://stackoverflow.com/questions/37897523/axios-get-access-to-response-header-fields
Axios get access to response header fields
I'm building a frontend app with React and Redux and I'm using axios to perform my requests. I would like to get access to all the fields in the header of the response. In my browser I can inspect ...
stackoverflow.com
https://soobakba.tistory.com/30
axios로 파일 다운로드 및 Content-Disposition 정보 사용하기
파일 다운로드 기능을 구현하면서 약간의 삽질을 하면서 애를 먹었는데 덕분에 새로운 사실들을 알게 되었다. 서버에서 ByteArray 값을 내려주는 경우 파일로 만들어 내려받기 서버에서 response hea
soobakba.tistory.com
반응형
댓글