N
N
newbee2017-07-25 13:21:15
PHP
newbee, 2017-07-25 13:21:15

Angular 2 how to override server from nodejs to apache(openServer) and comment sub-question?

Angular2 (build from the creators), when deployed, drags a lite server or some other, that's not the point.
Well, browserify, that's all. Comfortable, no doubt.
Explain, who knows, whether it is possible to redefine the server in such an assembly to php-shny, while maintaining browserify, and if so, how.
But another question is more important - if you do not do this (do not override), it turns out that such an application may not need a centralized server, and somehow you can think about the client-client architecture, throwing the (centralized) server out of this scheme as a link?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dummyman, 2017-07-25
@dummyman

In essence, you need to inject a proxy inside your node server.
Separately, this is done somehow like this:

var http = require('http');

http.createServer(onRequest).listen(3000);

function onRequest(client_req, client_res) {
  console.log('serve: ' + client_req.url);

  var options = {
    hostname: 'www.google.com',
    port: 80,
    path: client_req.url,
    method: 'GET'
  };

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

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

Code taken from here .
In fact , when you log http://127.0.0.1:3000/in, you get a workable google.
True, I did not check the code. But it looks to be working.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question