File upload via node proxy

I am working with a node proxy to redirect API requests to another server. This works fine, but not for downloading files. Apparently, the headers are set correctly, but somehow the image is not being processed on the "destination" server. What should I do?. Thank!

    function pipeRequest(client_req, client_res, method) {
        var options = {
           hostname: HOSTNAME,
           port: PORT,
            path: client_req.url,
            method: method
        };

        var proxy = http.request(options, function (res) {
           res.pipe(client_res, {
              end: true
           });
         });

         if(client_req.url === "/ops/blong/image/upload"){
            console.log(client_req.headers['content-type']);
         }

         client_req.pipe(proxy, {
            end: true
         });
     }

    function onRequest(client_req, client_res) {
          var my_path = url.parse(client_req.url).pathname,
          full_path = path.join(process.cwd(), my_path);

         //Forward API calls
         if (client_req.method === 'POST') {
              pipeRequest(client_req, client_res, 'POST');

              //Return local files for static content
         }  else {
               filesys.exists(full_path, function (exists) {
                 bla bla bla....
+4
source share

All Articles