{"id":19077893,"url":"https://github.com/backendstack21/fast-proxy-lite","last_synced_at":"2025-08-14T08:41:15.259Z","repository":{"id":44624244,"uuid":"425798974","full_name":"BackendStack21/fast-proxy-lite","owner":"BackendStack21","description":"Node.js framework agnostic library that enables you to forward an http request to another HTTP server. Supported protocols: HTTP, HTTPS","archived":false,"fork":false,"pushed_at":"2024-01-19T19:52:29.000Z","size":32,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T12:06:56.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BackendStack21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://www.paypal.me/kyberneees"}},"created_at":"2021-11-08T10:48:35.000Z","updated_at":"2023-07-06T07:58:49.000Z","dependencies_parsed_at":"2024-01-19T21:04:40.719Z","dependency_job_id":"bc954633-5055-44c8-8011-b894afd6d929","html_url":"https://github.com/BackendStack21/fast-proxy-lite","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.125,"last_synced_commit":"c2ed923ae6694204253ca502a4663d2c8f0a1a14"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackendStack21%2Ffast-proxy-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackendStack21%2Ffast-proxy-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackendStack21%2Ffast-proxy-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackendStack21%2Ffast-proxy-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BackendStack21","download_url":"https://codeload.github.com/BackendStack21/fast-proxy-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251644176,"owners_count":21620615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T02:03:51.855Z","updated_at":"2025-04-30T04:34:12.293Z","avatar_url":"https://github.com/BackendStack21.png","language":"JavaScript","funding_links":["https://www.paypal.me/kyberneees"],"categories":[],"sub_categories":[],"readme":"# fast-proxy-lite\nNode.js framework agnostic library that enables you to forward an http request to another HTTP server. \nSupported proxy protocols: HTTP, HTTPS\n\n\u003e This library was initially forked from `fast-proxy`: https://github.com/fastify/fast-proxy\n\n`fast-proxy-lite` powers: https://www.npmjs.com/package/fast-gateway 🚀 \n## Install\n```\nnpm i fast-proxy-lite\n```\n\n## Usage\nThe following examples describe how to use `fast-proxy-lite` with `restana`:\n\nGateway:\n```js\nconst { proxy, close } = require('fast-proxy-lite')({\n  base: 'http://127.0.0.1:3000'\n  // options\n})\nconst gateway = require('restana')()\n\ngateway.all('/service/*', function (req, res) {\n  proxy(req, res, req.url, {})\n})\n\ngateway.start(8080)\n```\n\nRemote service:\n```js\nconst service = require('restana')()\nservice.get('/service/hi', (req, res) =\u003e res.send('Hello World!'))\n\nservice.start(3000)\n```\n\nUsing imports:\n```ts\nimport fastProxy from 'fast-proxy-lite'\n\nconst { proxy, close } = fastProxy({\n  base: 'http://127.0.0.1:3000'\n})\n```\n\n## Benchmarks\nPlease see: https://github.com/jkyberneees/nodejs-proxy-benchmarks\n\n## API\n\n### Options\n#### `base`\nSet the base URL for all the forwarded requests.\n\n#### cacheURLs\nThe number of parsed URLs that will be cached. Default: 100.\n\u003e Use value = `0` to disable the caching mechanism\n\n#### requests.http and requests.https\nAllows to optionally overwrite the internal `http` and `https` client agents implementation. Defaults: [`http`](https://nodejs.org/api/http.html#http_http) and [`https`](https://nodejs.org/api/https.html#https_https).\n\nFor example, this could be used to add support for following redirects, like so:\n\n```js\n...\n  requests: {\n    http: require('follow-redirects/http'),\n    https: require('follow-redirects/https')\n  }\n...\n```\n\n#### keepAliveMsecs\nDefaults to 1 minute, passed down to [`http.Agent`][http-agent] and\n[`https.Agent`][https-agent] instances.\n\n#### maxSockets\nDefaults to 2048 sockets, passed down to [`http.Agent`][http-agent] and\n[`https.Agent`][https-agent] instances.\n\n#### rejectUnauthorized\nDefaults to `true`, passed down to [`https.Agent`][https-agent] instances.\nThis needs to be set to `false` to reply from https servers with\nself-signed certificates.\n\n#### Extended configurations\nOther supported configurations in https://nodejs.org/api/http.html#http_new_agent_options can also be part of the `opts` object.\n\n### close\nOptional _\"on `close` resource release\"_ strategy. You can link this to your application shutdown hook as an example.\n\n### proxy(originReq, originRes, source, [opts])\nEnables you to forward an http request to another HTTP server.\n```js\nproxy(\n  originReq,                          // http.IncomingMessage \n  originRes,                          // http.ServerResponse\n  req.url,                            // String -\u003e remote URL + path or path if base was set\n  {}                                  // Options described below\n)\n```\n#### opts\n\n##### base\nOptionally indicates the base URL for the current request proxy. When used, the global `base` config is overwriten.  \n\n##### onResponse(req, res, stream)\nCalled when an http response is received from the source.\nThe default behavior is `pump(stream, res)`, which will be disabled if the\noption is specified.\n\n##### onClientConnectionTerminated(res, err, response)\nCalled when the client HTTP connection to the proxy server unexpectedly terminates before the downstream service response is sent.  \n```js\n// internal implementation\nif (!res.socket || res.socket.destroyed || res.writableEnded) {\n  return onClientConnectionTerminated(res, err, response)\n}\n```\n\n##### rewriteRequestHeaders(req, headers)\nCalled to rewrite the headers of the request, before them being sent to the downstream server. \nIt must return the new headers object.\n\n##### rewriteHeaders(headers)\nCalled to rewrite the headers of the response, before them being copied\nover to the outer response.\nIt must return the new headers object.\n\n##### request\nExtended options supported by `http[s].request` method (https://nodejs.org/api/http.html#http_http_request_options_callback)  \n\u003e The following options are dynamically assigned: `method, port, path, hostname, headers, agent`.  \n\n##### queryString\nReplaces the original querystring of the request with what is specified.\n\n## Related topics\n- http-agent: https://nodejs.org/api/http.html#http_new_agent_options\n- https-agent: https://nodejs.org/api/https.html#https_class_https_agent\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendstack21%2Ffast-proxy-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackendstack21%2Ffast-proxy-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendstack21%2Ffast-proxy-lite/lists"}