I have a local server (Vera home automation controller) that will accept an 
http request like this:

http://10.0.1.25:3480/data_request?id=status&output_format=json&DeviceNum=3

but nas no whitelist or CORS support.  It works in a browser, but I cannot 
access using AJAX.

It was suggested that I use a proxy to get the return, but i cannot get it 
to work.

Can anyone give advice on what to try?

I've tried this and it works for websites, but not this little server:

var http = require('http'),
    net = require('net'),
    httpProxy = require('http-proxy'),
    url = require('url'),
    util = require('util');

var proxy = httpProxy.createServer();

var server = http.createServer(function (req, res) {
  util.puts('Receiving reverse proxy request for:' + req.url);

  proxy.web(req, res, {target: req.url, secure: false});
}).listen(8213);

server.on('connect', function (req, socket) {
  util.puts('Receiving reverse proxy request for:' + req.url);

  var serverUrl = url.parse('http://' + req.url);  //https!!

  var srvSocket = net.connect(serverUrl.port, serverUrl.hostname, 
function() {
    socket.write('HTTP/1.1 200 Connection Established\r\n' +
    'Proxy-agent: Node-Proxy\r\n' +
    '\r\n');
    srvSocket.pipe(socket);
    socket.pipe(srvSocket);
  });
});


help?


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/6cb206ba-a211-47d1-a2f7-e0372ae80f14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to