node.js - Modify headers before proxifying the request -


i have app running locally, on http://localhost:9000

now, want achieve mask url of app. is, want set nodejs app, @ http://localhost:8000 proxy requests above mentioned app.

i tried following, using express , http-proxy modules:

var app = require('express')(),     proxy = require('http-proxy').createproxy({});  app.get('*', function(req, res) {     proxy.web(req, res, {         target: "http://localhost:9000"     }); });  app.post('*', function(req, res) {     proxy.web(req, res, {         target: "http://localhost:9000"     }); });  app.listen(8000); 

this works requests not post ones. so, guessing have change request headers in way make work. right here?

if yes, obliged if can guide me how in appropriate way.

later on, thought of changing proxy target http://www.google.com (rather localhost:9000). throws 404 error. not google, whatever target tried, 404 every time. why so? (i wasn't able information network monitor in dev tools also)

what previous google searches that, can done using nginx (right?). know if doable node, possibly using other node modules well?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -