简体   繁体   中英

How can you redirect to a logon page for cross-domain requests?

In an application where I am making cross-domain JSONP requests (using jQuery), when the browser makes the first jsonp request, it pops up a dialog for basic authentication, because that is what the target server requires. I would instead like to trap the event and bring up a dialog with a logon page from the server hosting the resource to establish authentication. How can I do this?

I think it is not possible, only option is to disable basic authentication and for end users, shouldn't that be disabled?

I agree with Adeel... it can't be trapped.

However, you can supply the required authentication header manually - to prevent the prompt from ever appearing - if the user has already "logged in" and you know their un/pw on the client side.

Per this thread How do I make a JSONP call with JQuery with Basic Authentication? it seems like you would need to proxy all the requests through server-side to detect and override http-level authentication challenges.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM