http status为401时,避免浏览器弹出认证框

Basic认证失败时,接口返回的http status code = 401时,大部分浏览器会弹出下图的认证窗口来辅助用户完成认证。

《http status为401时,避免浏览器弹出认证框》

这时,要点击取消才能进入到axios catch function。
解决到方法很简单,在response headers中去除 WWW-Authenticate: Basic realm=”Realm” 即可。

    原文作者:Layla
    原文地址: https://segmentfault.com/a/1190000019544956
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞