How to prevent safari showing login form when calling a restful api with HTTP basic Authentication

StackOverflow https://stackoverflow.com/questions/21542691

문제

In my project my client side web application calls my back-end server which is a restful API sercured with HTTP baisc authentication, it runs perfect in chrome and firefox, but within the safari it always shows the HTTP basic login form, how could I prevent it to pop up in the client side.

And the client side app validates user login by calling the restful api and returns 401 automatically at the begining.

enter image description here

올바른 솔루션이 없습니다

다른 팁

See an analysis of the problem here.

We had the same problem only with a recent Safari version (all other versions were fine), and the cleanest fix was to modify the "www-authenticate" header so that it doesn't return a Basic or Digest challenge.

Thus, the API url will never trigger the popup (whether it's called via Ajax or directly). Up to you to decide whether it's okay for your use case.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top