{"bugs":{"url":"https://github.com/fastify/fastify-http-proxy/issues"},"dist":{"shasum":"25fab9b30c9952899209e275a025045a9e5334a8","tarball":"https://registry.npmjs.org/fastify-http-proxy/-/fastify-http-proxy-2.0.1.tgz","fileCount":12,"integrity":"sha512-7RfBUUi+j5Sp5MZ+kKr9I7U1exar4EiKxN1K6zQXjheY/y7+iUx/Idgw0P/tjn3kOjFtHQAQ3JEX/Fk0na5kbg==","signatures":[{"sig":"MEQCIHVPDcOrbGC/WE/561N3scgl+UAkFGLZOVyWh3hC07jsAiA3OjXLHzMBu5swbJK/kSK0BlA5wCEH2w31gzWyxfnAcw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16811,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcV+8MCRA9TVsSAnZWagAABUQP/igbdidxj6EB8OBbQ71b\nrMRuL5u93oTmrnXQJVYPIoe8HySzYaR1dyA+Eks0Iqej3x5DjX9aWhLM2D3C\nLoUP3OWW7YN1CbmB7zNjQLtSiQeHDtEEpjNT1iLxnPUlhUtFm1OkaiFk0HeF\n+w281oIXifrej8POKk2W0VOeEhOP7SRjMzu5ZOVRSo1w5KSN+OFf1FpsK3rI\n4AZGbzgYUTIlBLz4QTG9FKBx/v1CJ45OoYLbNm3oMuRcHuAwHn9HJNytA0WT\nvzxEY6m2qy0WhI5i5aeH0AKnfK08K7kaAcpS0mH/jT7Ze15j2XEd+ZpfQrhu\n+v9fOOzzY6VBcV21WoDB61jeMk9urVW2b7n18UieruQ3yuEsh/iDATIL6RUw\n7Gk0UlefIv3an9ze7tXYSkUeTQeykw/XZRyUXbBAbW5GHoAbJH15UO7282Wy\nv4KuIB2liC0EZAPtRbgMQ3PiMn1voJbddtHDu3qe669B1KuYk5p44lHCbJcQ\nWCMJrM4zLy6/yQYZo9l7ymwUhfJnL1sxUskh+0hrXrU+TNxT88FXPxUbIR5g\ngKqQGCOgivrxRaGGaDs1Yj9RbLQ8XJaBOU1XZJFGUgmd2mZmw6PetCNNDxuB\neGSB7SIVJKEH9Lr7o09UL9dfnKoD7RS0fhXsksgAqZ7jG7uMgCZULEGyo+2R\nhfpR\r\n=Vj8/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"fastify-http-proxy","author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"readme":"# fastify-http-proxy\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-http-proxy.svg)](https://greenkeeper.io/)\n\n[![Build Status](https://travis-ci.org/fastify/fastify-http-proxy.svg?branch=master)](https://travis-ci.org/fastify/fastify-http-proxy)\n\nProxy your http requests to another server, with hooks.\nThis [`fastify`](https://www.fastify.io) plugin forward all the request\nreceived with a given prefix (or none) to an upstream. All Fastify hooks are still applied.\n\n`fastify-http-proxy` is built on top of\n[`fastify-reply-from`](http://npm.im/fastify-reply-from), which enables\nyou for single route proxying.\n\nThis plugin can be used in a variety of circumstances, for example if you have to proxy an internal domain to an external domain (useful to avoid CORS problems) or to implement your own API gateway for a microservices architecture.\n\n## Requirements\n\nFastify 2.x. See [this branch](https://github.com/fastify/fastify-http-proxy/tree/1.x) and related versions for Fastify 1.x compatibility.\n\n## Install\n\n```\nnpm i fastify-http-proxy fastify\n```\n\n## Example\n\n```js\nconst Fastify = require('fastify')\nconst server = Fastify()\n\nserver.register(require('fastify-http-proxy'), {\n  upstream: 'http://my-api.example.com',\n  prefix: '/api', // optional\n  http2: false // optional\n})\n\nserver.listen(3000)\n```\n\nThis will proxy any request starting with `/api` to `http://my-api.example.com`. For instance `http://localhost:3000/api/users` will be proxied to `http://my-api.example.com/users`.\n\nIf you want to have different proxies on different prefixes in you can register multiple instances of the plugin as shown in the following snippet:\n\n```js\nconst Fastify = require('fastify')\nconst server = Fastify()\nconst proxy = require('fastify-http-proxy')\n\nserver.register(proxy, {\n  upstream: 'http://my-api.example.com',\n  prefix: '/api', // optional\n  http2: false // optional\n})\n\nserver.register(proxy, {\n  upstream: 'http://single-signon.example.com/auth',\n  prefix: '/auth', // optional\n  http2: false // optional\n})\n\nserver.listen(3000)\n```\n\nNotice that in this case it is important to use the `prefix` option to tell the proxy how to properly route the requests across different upstreams.\n\nFor other examples, see `example.js`.\n\n## Options\n\nThis `fastify` plugin supports _all_ the options of\n[`fastify-reply-from`](https://github.com/fastify/fastify-reply-from) plus the following.\n\n*Note that this plugin is fully encapsulated, and non-JSON payloads will\nbe streamed directly to the destination.*\n\n### upstream\n\nAn URL (including protocol) that represents the target server to use for proxying.\n\n### prefix\n\nThe prefix to mount this plugin on. All the requests to the current server starting with the given prefix will be proxied to the provided upstream.\n\nThe prefix will be removed from the URL when forwarding the HTTP\nrequest.\n\n### rewritePrefix\n\nRewrite the prefix to the specified string. Default: `''`.\n\n### preHandler\n\nA `preHandler` to be applied on all routes. Useful for performing actions before the proxy is executed (e.g. check for authentication).\n\n### replyOptions\n\nObject with [reply options](https://github.com/fastify/fastify-reply-from#replyfromsource-opts) for `fastify-reply-from`.\n\n## Benchmarks\n\nThe following benchmarks where generated on a Macbook 2018 with i5 and\n8GB of RAM:\n\n| __Framework__ | req/sec |\n| :----------------- | :------------------------- |\n| `express-http-proxy` | 878.4 |\n| `http-proxy` | 3837 |\n| `fastify-http-proxy` | 4205 |\n| `fastify-http-proxy` (with [`undici`](https://github.com/mcollina/undici)) | 6235.6 |\n\nThe results where gathered on the second run of `autocannon -c 100 -d 5\nURL`.\n\n## TODO\n\n* [ ] Generate unique request ids and implement request tracking\n* [ ] Perform validations for incoming data\n\n## License\n\nMIT\n","gitHead":"5aea7b72195a18cb67469bb50a4f267c940c744f","license":"MIT","scripts":{"test":"standard | snazzy && tap test.js"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"homepage":"https://github.com/fastify/fastify-http-proxy#readme","keywords":["fastify","http","proxy"],"repository":{"url":"git+https://github.com/fastify/fastify-http-proxy.git","type":"git"},"_npmVersion":"6.7.0","description":"proxy http requests, for Fastify","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"ethan_arrowood","email":"ethan.arrowood@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"trivikr","email":"trivikr.dev@gmail.com"}],"_nodeVersion":"10.14.2","dependencies":{"fastify-reply-from":"^0.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"got":"^9.5.0","tap":"^12.1.1","snazzy":"^8.0.0","express":"^4.16.4","fastify":"^2.0.0-rc.4","standard":"^12.0.1","http-proxy":"^1.17.0","pre-commit":"^1.2.2","simple-get":"^3.0.3","http-errors":"^1.7.1","express-http-proxy":"^1.5.0","make-promises-safe":"^4.0.0"},"peerDependencies":{"fastify":"2.x"},"_npmOperationalInternal":{"tmp":"tmp/fastify-http-proxy_2.0.1_1549266699644_0.8234242249639883","host":"s3://npm-registry-packages"},"_id":"fastify-http-proxy@2.0.1","version":"2.0.1"}