// Use explicit /index.js to help browserify negociation in require '/lib/http-proxy' (!) var ProxyServer = require('./http-proxy/index.js').Server; /** * Creates the proxy server. * * Examples: * * httpProxy.createProxyServer({ .. }, 8000) * // => '{ web: [Function], ws: [Function] ... }' * * @param {Object} Options Config object passed to the proxy * * @return {Object} Proxy Proxy object with handlers for `ws` and `web` requests * * @api public */ function createProxyServer(options) { /* * `options` is needed and it must have the following layout: * * { * target : * forward: * agent : * ssl : * ws : * xfwd : * secure : * toProxy: * prependPath: * ignorePath: * localAddress : * changeOrigin: * preserveHeaderKeyCase: * auth : Basic authentication i.e. 'user:password' to compute an Authorization header. * hostRewrite: rewrites the location hostname on (201/301/302/307/308) redirects, Default: null. * autoRewrite: rewrites the location host/port on (201/301/302/307/308) redirects based on requested host/port. Default: false. * protocolRewrite: rewrites the location protocol on (201/301/302/307/308) redirects to 'http' or 'https'. Default: null. * } * * NOTE: `options.ws` and `options.ssl` are optional. * `options.target and `options.forward` cannot be * both missing * } */ return new ProxyServer(options); } ProxyServer.createProxyServer = createProxyServer; ProxyServer.createServer = createProxyServer; ProxyServer.createProxy = createProxyServer; /** * Export the proxy "Server" as the main export. */ module.exports = ProxyServer;