A
A
Alex_5142016-01-09 12:07:18
JavaScript
Alex_514, 2016-01-09 12:07:18

How to set up a proxy server for localhost?

So, there is a server on node js, a middleware that sends data to the client

var taskpath = __dirname + '\\public\\task.json';
console.log(taskpath);
app.post('/task', function(req, res){
  var readable = fs.createReadStream(taskpath);
    readable.pipe(res);
});

I use greasymonkey on the client that handles the request
GM_xmlhttpRequest({
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  url: 'http://localhost:8080/task',
  onload: function(data) {
    var json_text = JSON.stringify(data.response, null, 2),
      your_object = JSON.parse(json_text);
    var href = $('#guide-channels').find('li:contains(' + your_object[0].task[0].channel + ')').find('a').attr('href'),
      videos = 'http://www.youtube.com' + href + '/videos',
      channel = {};
    channel['channel'] = videos;
    /*GM_xmlhttpRequest({
      method: 'POST',
      data: JSON.stringify(channel),
      contentType: 'application/json',
      url: 'http://localhost:8081/getHttp',
      onload: function (xhr) {
        console.log('xhr__', xhr.responseText);
      }
    });*/
  }
});

Everything goes well, but that's when I install the proxy server. gives an error
and before that it gave out like this Please help me, which day I'm struggling with it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question