0

Is it possible to make javascript based web proxy, where the url entered by the user is fetched by the javascript directly without going to the proxy server ?

Ashni Goyal
  • 819
  • 3
  • 10
  • 20
  • Are you referring to make a cross-domain AJAX request? Would something like JSONP be what you are looking for? – Jonathan Harrison Dec 27 '12 at 21:12
  • Unless CORS is supported, or it's JSONP, no it's not possible without some server scripting or a service like YQL! – adeneo Dec 27 '12 at 21:12
  • What do you mean by "without going to the proxy server"? – Brad Dec 27 '12 at 21:13
  • Possible duplicate of [Ways to circumvent the same-origin policy](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy)? – apsillers Dec 27 '12 at 21:14
  • Your language about "proxy servers" is very unclear. Do you simply want to fetch a cross-domain Web resource using Ajax? – apsillers Dec 27 '12 at 21:17
  • I do not know what `JSONP` is. I want to make a proxy site, which uses javascript to fetch the desired url. Such request will not go to proxy server. Is it possible? Does it not conflict with "same origin policy" of browsers ? What ip address will be exposed if it is possible to make such a proxy ? – Ashni Goyal Dec 27 '12 at 21:18
  • @Brad I meant the request should not be served through the proxy server. Browser (or the JS code or for that matter any client side code) should directly fetch the url. – Ashni Goyal Dec 27 '12 at 21:36
  • @apsillers Yes, is it possible to fetch url using ajax ? Will browser allow such request as it might violate "same origin policy" ? – Ashni Goyal Dec 27 '12 at 21:37
  • javascript is interpreted by the browser on the user's machine. Any request will come from the current users browser (which may be using a proxy or not). You can possibly do this, but you would have to handle it with a server side application or by using some third party service. – Nick Bray Dec 27 '12 at 21:42
  • Where does a proxy server come into play? You mean your proxy server? Or the one the user has? Your question is all but incomprehensible. What exactly are you trying to do. Be specific. What do you mean by "I want to make a proxy site"? For what purpose? You realize that making requests with JavaScript is no different (on an HTTP level) than any other browser request, right? Perhaps you are looking for an iframe.... – Brad Dec 27 '12 at 21:49
  • @Brad There are many proxy sites like www.hidemyass.com. Now I want to build a similar site for same purpose. Difference is this. Everytime you request for a url using www.hidemyass.com, it will fetch the url via its own servers. I want my proxy site to fetch the requested url directly from the user browser using javascript instead of channeling the request through my server. I hope I am clear now, Kindly let me know if there is any doubt. – Ashni Goyal Dec 28 '12 at 11:20
  • @AshniGoyal, I still don't understand. You want to fetch the resource from the browser without going through your server... then there is no proxy! The request will come from the user's IP address, defeating the whole purpose of sites like those. – Brad Dec 28 '12 at 15:52
  • @Brad your are correct. althoguh i am calling it a proxy (since it is fetching url ), it does not protects user ip. but that is not an issue with my app. – Ashni Goyal Jan 04 '13 at 06:22
  • @AshniGoyal, Stop calling it a proxy server. There isn't one. Simply use an ` – Brad Jan 04 '13 at 14:33

1 Answers1

1

You are not going to be doing it with pure JavaScript unless the JavaScript happens to be running on the server.

You can use a service like Yahoo Pipes and get the page via a JSONP call.

epascarello
  • 204,599
  • 20
  • 195
  • 236
  • Thanks for your reply. Could you please explain why client side javascript will not work ? – Ashni Goyal Dec 28 '12 at 11:21
  • Have you not read about the Same Origin Policy - https://developer.mozilla.org/en-US/docs/JavaScript/Same_origin_policy_for_JavaScript – epascarello Dec 28 '12 at 14:18