Connect middleware to proxy (and optionally transform) requests to a different server
Connect proxy layer is a piece of connect middleware that allows you to send requests on to another end server. Additionally, you can define functions for the proxy to use to modify the request in-flight. If you do not specify interceptors the proxy will simply pipe data from the input, and proxy the response.
Using connect-proxy-layer is as simple as:
var cpl = require'connect-proxy-layer' connect = require'connect';var app = connect;appuse"/api" cpl"";applisten80;
####Header The header interceptor allows you to determine whether the requests needs additional transformation based upon information available in the headers and URL of the request.
####Input The input interceptor is what is called to transform "Proxied" requests to the server.
proxylocalRequest requestBody localResponse nxt;
####Output The output interceptor is called to modify response data from the server before it is sent to the client.
sendlocalResponse remoteResponse responseBody;
###NB To use the "input" interceptor you must define a header interceptor and call proxy(), because the default behavior is to pump the request.
This software is provided under a BSD 2-Clause license.