title: Catch all http requests and send urls to parent
body: <p>server.js</p>
  
  <pre><code>var http = require('http');
  var url = require('url');
  var request = require('request');
  var fs = require('fs');
  http.createServer(onRequest).listen(85);
  
  function onRequest(req, res) {
     if (req.url === "/"){
           fs.readFile('/index.html',function(data,err){
              if (err){
                  console.log(err);
                  return res.end(err);
              }
  
              res.write(data);
              res.end();
          });
      }
      var queryData = url.parse(req.url, true).query;
      if (queryData.url) {
          request({
              url: queryData.url
          }).on('error', function(e) {
              res.end(e);
          }).pipe(res);
      }
      else {
          res.end("no url found");
      }
  }
  </code></pre>
  
  <p>What this program does is get a file from a remote location of the user's choosing by adding a query parameter to the end of the url as follows</p>
  
  <p><code>www.myprogramdomain:85/?url=http://www.domain.com/index.html</code></p>
  
  <p>If I try to do the above bet set <code>url=http://us.battle.net</code> It shows a webpage without the css. I go into the browser console and see that the page does not have any css or javascript because the scripts are included with local tags such as '/scripts/myscript.js' or something. What I plan to do is embed the webdata from the server inside of an iframe and intercept the requests for files as they come. </p>
  
  <p>The question is, inside of the iframe, how do I intercept http requests and get the url the request is trying to send to the server. Preferably as a string. I searched around for a long time. I even attempted to replace all instances of 'http' with '<a href="http://www.myprogramdomain.com:85/?url=http" rel="nofollow">http://www.myprogramdomain.com:85/?url=http</a>' but that did not work as expected as some of the urls such as '/scripts/js.js' do not have 'http' in it. That's why I want to be able to intercept requests and get the urls from the request. Or maybe I want to run a script every time an http request is made from the iframe.</p>
  
  <p><strong>What I want to do is intercept the http request inside of the iframe and replace it with my own request.</strong></p>
  
  <p>If you need some more explanation DO NOT BE AFRAID TO ASK FOR MORE INFORMATION!</p>