0
votes

I want to make an ajax request from IBM Connections XCC:

let api = 'https://my-server2/api.xml'
var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = () => {
    if (xmlhttp.readyState == XMLHttpRequest.DONE) 
       if (xmlhttp.status == 200) {
           console.log(xmlhttp.responseText)
       }else {
           console.log(`Error: ${xmlhttp.readyState}`)
       }
}

Result in the network tab is a request to https://connections-host/communities/ajaxProxy/https/my-server2/api.xml so the request is proxied over the connections server. Because of this I get an empty API result since I need an authorized user session. My idea was: The user is logged in in his browser on my-server2 application. So when making an ajax request to my-server2, I can get the API information in his user context.

So my question is: How can I bypass those proxy?

Since I don't set it, I assume that connections manipulate the XMLHttpRequest class in a way like this: https://gist.github.com/dewdad/8830348

I want to view it's code to see the manipulation with this code in the console, but it only shows native code

window.XMLHttpRequest.prototype.open.toString()
    "function open() {
        [native code]
}"
1

1 Answers

0
votes

Connections uses an AJAX proxy to control what's sent out to non-Connections sites/apps. You can configure it for your site to allow specific methods, headers and cookies to be sent to the non-Connections site. I'd take a look at this document on Connections 6.0 https://www.ibm.com/support/knowledgecenter/en/SSYGQH_6.0.0/admin/secure/t_admin_config_ajax_proxy_feature.html

I think that should help you get what you want.