Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Proxy Middleware / Response Modification Support #11

Open
wei opened this issue May 17, 2016 · 1 comment
Open

Post Proxy Middleware / Response Modification Support #11

wei opened this issue May 17, 2016 · 1 comment

Comments

@wei
Copy link

wei commented May 17, 2016

Hi there,

Is there any support for post proxy middleware or response modification? I'm looking to replace urls in the response html and js files.

Thanks!
ddhhz

@Tornado-Tim
Copy link
Contributor

Hi ddhhz,
You can manipulate urls by adding another function using the use directive.
ie:

var RedWire = require('redwire');
var redwire = new RedWire({
    http: { port: 80 }
});

redwire.http('example.com', '127.0.0.1:3000');

manipulate = function(mount, url, req, res, next) {
    if (req.url.indexOf('/testplace/') === 0) {
      req.url += 'add this';
      url += 'add this';
    }
    return redwire.proxy()(mount, url, req, res, next);
  };

redwire.http('example.com/api').use(manipulate);

Hope this helps.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants