File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -500,6 +500,7 @@ View the [recipes](https://github.com/chimurai/http-proxy-middleware/tree/master
500500
501501- [ connect] ( https://www.npmjs.com/package/connect )
502502- [ express] ( https://www.npmjs.com/package/express )
503+ - [ fastify] ( https://www.npmjs.com/package/fastify )
503504- [ browser-sync] ( https://www.npmjs.com/package/browser-sync )
504505- [ lite-server] ( https://www.npmjs.com/package/lite-server )
505506- [ polka] ( https://github.com/lukeed/polka )
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Missing a server? Feel free to extend this list of examples.
99- [ Browser-Sync] ( #browser-sync )
1010- [ Express] ( #express )
1111- [ Connect] ( #connect )
12+ - [ fastify] ( #fastify )
1213- [ lite-server] ( #lite-server )
1314- [ Polka] ( #polka )
1415- [ grunt-contrib-connect] ( #grunt-contrib-connect )
@@ -83,6 +84,33 @@ app.use(apiProxy);
8384http .createServer (app).listen (3000 );
8485```
8586
87+ ## fastify
88+
89+ https://github.com/fastify/fastify [ ![ GitHub stars] ( https://img.shields.io/github/stars/fastify/fastify.svg?style=social&label=Star )] ( https://github.com/lukeed/polka )
90+
91+ ``` javascript
92+ const fastify = require (' fastify' )({ logger: true });
93+ const { createProxyMiddleware } = require (' http-proxy-middleware' );
94+
95+ (async () => {
96+ await fastify .register (require (' fastify-express' ));
97+
98+ const proxy = createProxyMiddleware ({
99+ target: ' http://jsonplaceholder.typicode.com' ,
100+ changeOrigin: true ,
101+ });
102+
103+ fastify .use (proxy);
104+
105+ fastify .listen (3000 , (err , address ) => {
106+ if (err) throw err;
107+ fastify .log .info (` server listening on ${ address} ` );
108+ });
109+ })();
110+
111+ // curl http://localhost:3000/users
112+ ```
113+
86114## lite-server
87115
88116https://github.com/johnpapa/lite-server
You can’t perform that action at this time.
0 commit comments