2

My application is in PHP and AngularJS (migrating from PHP to AngularJS).

Let us say the Apache HTTPD server is on domain1 and the backend (Apache Tomcat) is on domain2.

When I request for apps which are in AngularJS, the JavaScript files are loaded from domain1. After the browser has loaded of all JavaScript files, AngularJS kicks in and the client requests for data from domain2.

The domain2 server wants to authenticate the caller and so responds the browser with a status code 401 and header WWW-Authenticate: Basic.

With Chrome, Firefox and IE, the browser prompts for a username and password (the prompt is the browser in-built one not my custom made). In Safari it does not, instead in the Safari console I get the following message -

http://domain2/request
Failed to load resource: the server responded with a status 401 (Unauthorized)

The backend server has CORS enabled.

JHS
  • 7,761
  • 2
  • 29
  • 53
  • http://stackoverflow.com/questions/16139660/angularjs-basic-example-to-use-authentication-in-single-page-application – Ram Nov 18 '15 at 13:53
  • @Vohuman - Thank you, but it does not help me as I want the browser to prompt for the username and password. I do not have a login page. – JHS Nov 18 '15 at 13:58
  • Just ran into this same issue. Not sure if it’s a bug or by design, but Safari appears to be the only browser to not honour a Basic WWW-Authenticate challenge on a cross-origin request. – Neil Madden Apr 25 '19 at 05:49

0 Answers0