How to get current server node number from Session HAProxy is used in Data Center setup

How to get current server node info from the session when HAProxy is used in DC setup.
When we try to get the JSESSIONID cookie from HttpServletRequest, getting Session Id without server node part (s1~). If we use the same for subsequent REST APIs, getting 401 Unauthorized errors. We need to pre-pend the server node number along with session id to access any Confluence REST APIs from the add-on (app) code.