Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
fast-proxy-lite
Advanced tools
Node.js framework agnostic library that enables you to forward an http request to another HTTP server. Supported proxy protocols: HTTP, HTTPS
This library was initially forked from
fast-proxy
: https://github.com/fastify/fast-proxy
fast-proxy-lite
powers: https://www.npmjs.com/package/fast-gateway 🚀
npm i fast-proxy-lite
The following examples describe how to use fast-proxy-lite
with restana
:
Gateway:
const { proxy, close } = require('fast-proxy-lite')({
base: 'http://127.0.0.1:3000'
// options
})
const gateway = require('restana')()
gateway.all('/service/*', function (req, res) {
proxy(req, res, req.url, {})
})
gateway.start(8080)
Remote service:
const service = require('restana')()
service.get('/service/hi', (req, res) => res.send('Hello World!'))
service.start(3000)
Using imports:
import fastProxy from 'fast-proxy-lite'
const { proxy, close } = fastProxy({
base: 'http://127.0.0.1:3000'
})
Please see: https://github.com/jkyberneees/nodejs-proxy-benchmarks
base
Set the base URL for all the forwarded requests.
The number of parsed URLs that will be cached. Default: 100.
Use value =
0
to disable the caching mechanism
Allows to optionally overwrite the internal http
and https
client agents implementation. Defaults: http
and https
.
For example, this could be used to add support for following redirects, like so:
...
requests: {
http: require('follow-redirects/http'),
https: require('follow-redirects/https')
}
...
Defaults to 1 minute, passed down to [http.Agent
][http-agent] and
[https.Agent
][https-agent] instances.
Defaults to 2048 sockets, passed down to [http.Agent
][http-agent] and
[https.Agent
][https-agent] instances.
Defaults to true
, passed down to [https.Agent
][https-agent] instances.
This needs to be set to false
to reply from https servers with
self-signed certificates.
Other supported configurations in https://nodejs.org/api/http.html#http_new_agent_options can also be part of the opts
object.
Optional "on close
resource release" strategy. You can link this to your application shutdown hook as an example.
Enables you to forward an http request to another HTTP server.
proxy(
originReq, // http.IncomingMessage
originRes, // http.ServerResponse
req.url, // String -> remote URL + path or path if base was set
{} // Options described below
)
Optionally indicates the base URL for the current request proxy. When used, the global base
config is overwriten.
Called when an http response is received from the source.
The default behavior is pump(stream, res)
, which will be disabled if the
option is specified.
Called when the client HTTP connection to the proxy server unexpectedly terminates before the downstream service response is sent.
// internal implementation
if (!res.socket || res.socket.destroyed || res.writableEnded) {
return onClientConnectionTerminated(res, err, response)
}
Called to rewrite the headers of the request, before them being sent to the downstream server. It must return the new headers object.
Called to rewrite the headers of the response, before them being copied over to the outer response. It must return the new headers object.
Extended options supported by http[s].request
method (https://nodejs.org/api/http.html#http_http_request_options_callback)
The following options are dynamically assigned:
method, port, path, hostname, headers, agent
.
Replaces the original querystring of the request with what is specified.
MIT
FAQs
Forward your HTTP request to another server.
We found that fast-proxy-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.