Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Domain Request to localhost

DISCLAIMER: I've already looked at various approaches to solve my issue, so please read this before labeling this as a duplicate question

I have a javascript running on https://xyz.com which has to retrieve information from an application ABC running on the user's local machine say port 8080.

My constraints are that I cannot modify the HTTP headers emanating form the ABC nor do I want the user to install another application which will be a conduit to route my requests through to ABC.

Cross-Domain/Window Messaging Options

a) window.postMessage: Ruled out since I cannot have script running on the local machine
b) XDR Object (IE) or Access-Control-Allow-Origin (Firefox,Safari et al): Ruled out since I cannot modify the header
c) JSONP: Again this will not work since I am unable to enclose the response within the function name

As a workaround, only meant for testing I've added the http://xyz.com to the trusted list and have enabled Access Data Across Domains for sites on this list. AFAIK, this option is only available on IE 5+ browsers. This workaround allows me to send and receive messages from http://127.0.0.1:8080
alt text

My question is two-fold
1) If I were to continue with the above approach when I go into production what are the security implications that I'm exposing the user to? Can I plug those holes?
2) Are there any other options that I can pursue to achieve my objective.

PS: I would like to be as far away from ActiveX or Flash as possible, but in case that is the only workable alternative to my current approach then I'll have to toe the line

Cheers

like image 273
Philar Avatar asked Jun 11 '26 05:06

Philar


1 Answers

If the local application could serve a single html document, to act as a bridge, then you could easily use Cross-Document Messaging (for instance with easyXDM) together with ajax requests from this document to do this. This is a very simple approach and one commonly used.

easyXDM actually comes with such a document, you can read about it here.

like image 137
Sean Kinsey Avatar answered Jun 13 '26 20:06

Sean Kinsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!