前端獲取后端設置的自定義頭,前端獲取不到后端設置的response headers


需要后端設置 Access-Control-Expose-Headers

例如:后端在返回頭中設置 user-name: 張三

但是前端直接response.headers['user-name']是拿不到的

需要后端設置

1  Access-Control-Expose-Headers: user-name

前端才能順利拿到

    response.headers['user-name']  // => "張三"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。