How to prevent browser to invoke basic auth popup and handle 401 error using Jquery?

后端 未结 11 1236
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 12:18

I need to send authorization request using basic auth. I have successfully implemented this using jquery. However when I get 401 error basic auth browser popup is opened and

11条回答
  •  眼角桃花
    2020-11-27 13:02

    Make an /login url, than accept "user" and "password" parameters via GET and don't require basic auth. Here, use php, node, java, whatever and parse your passwd file and match parameters (user/pass) against it. If there is a match then redirect to http://user:pass@domain.com/ (this will set credential on your browser) if not, send 401 response (without WWW-Authenticate header).

提交回复
热议问题