2 years ago

#42795

test-img

Shahrukh Ahmed Khan

Microsoft Outlook Add-in can't extract/pass data to a localhost server via Ajax

I'm trying to build an Outlook add-in for encrypting/decrypting emails. The Add-in itself uses a web app, which in turn uses Javascript. I basically want to pass the unencrypted/encrypted email to a local server running python using GET/POST requests, perform some encryption/decryption on it in python, and then pass it back to Outlook Add-in. The problem is that the Add-in just won't pass any data to the local server nor get something in return. I have tried to work with both Django and Flask with the same results. I also configured the local servers to use locally-generated certificates and keys with no improvement. I even tried routing the HTTP connection using ngrok, but none came of it.

Server response to GET request on HTTP

Server response to GET request on HTTPS using Werkzeug

The code given below never returns "Here5" on item-status. Clearly the success snippet isn't being run.

 $.ajax({
            url: "https://127.0.0.1:8000/getPost/hello/",
            type: 'GET',
            dataType: 'json', // added data type
            success: function (res) {
                $('#item-status').text("Here5");
                $('#item-message').text(res);
            }
        });

I've also added the required URLs in the App Domain part of the manifest file:

<AppDomain>https://127.0.0.1:8000/getPost/hello/</AppDomain>

The Add-in performs fine when running GET requests from other sites on the internet, like: https://api.github.com/users However, I just can't seem to run it on my local server. How do I solve this?

Edit: After some debugging, I've learned that XMLHttpRequest status is 0 and responseText is empty. I think it might have something to do with CORS. Am I correct in that assumption? If yes, then how do I disable Cross Origin for localhost in this particular case?

Thank You

javascript

django

ajax

outlook-addin

outlook-web-addins

0 Answers

Your Answer

Accepted video resources