{"repo":"fastify/fastify-http-proxy","free":true,"listed":false,"github":"https://github.com/fastify/fastify-http-proxy","clone":"git clone https://github.com/fastify/fastify-http-proxy.git","description":"Proxy your http requests to another server, with hooks","language":"JavaScript","stars":392,"topics":["fastify","fastify-plugin","api-gateway","http-proxy","proxy"],"license":"MIT","category":"networking-infra","readme_excerpt":"@fastify/http-proxy Proxy your HTTP requests to another server, with hooks. This fastify plugin forwards all requests received with a given prefix (or none) to an upstream. All Fastify hooks are still applied. @fastify/http-proxy is built on top of @fastify/reply-from , which enables single route proxying. This 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. Requirements Fastify 5.x. See @fastify/http-proxy v9.x for Fastify 4.x compatibility. Install Example This 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 . If you want to have different proxies on different prefixes you can register multiple instances of the plugin as shown in the following snippet: Notice 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. Also, notice paths in upstream are ignored, so you need to use rewritePrefix to specify the target base path. For other examples, see example.js . Request tracking @fastify/http-proxy can track and pipe the request-id across the upstreams. Using the hyperid module and the @fastify/reply-from built-in options a fairly simple example would look like this: Options This fastify plugin sup","default_branch":null,"files":null,"tree":[],"storefront":"/r/fastify","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/fastify/fastify-http-proxy/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}