Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Obsolete
-
8.0.1
-
None
-
-
NEW
-
NEW
Description
When you try to do an AJAX Request to a back-end API that uses the node-js-adapter of keycloak ( https://github.com/keycloak/keycloak-nodejs-connect )
with an expired token, then the middle-ware tries to redirect to the login page but unfortunately ajax cant handle the 302 redirect from the middle-ware.
After searching through the code of the middle-ware i found that this is happening in the forceLogin function in the protect.js file.
One workaround that i found in order to solve this problem is to check if the request is typeof xhr and then send 401. By doing that the browser will redirect to login page. Of course i dont know if that is the correct way of doing that and for that i am opening a ticket.
// Code that was added to forceLogin Function
if(request.xhr)
else
{ response.redirect(loginURL); }