@@ -57,13 +57,12 @@ _All_ `http-proxy` [options](https://github.com/nodejitsu/node-http-proxy#option
5757- [ Install] ( #install )
5858- [ Core concept] ( #core-concept )
5959- [ Example] ( #example )
60+ - [ app.use(path, proxy)] ( #appusepath-proxy )
6061- [ Context matching] ( #context-matching )
6162- [ Options] ( #options )
6263 - [ http-proxy-middleware options] ( #http-proxy-middleware-options )
6364 - [ http-proxy events] ( #http-proxy-events )
6465 - [ http-proxy options] ( #http-proxy-options )
65- - [ Shorthand] ( #shorthand )
66- - [ app.use(path, proxy)] ( #appusepath-proxy )
6766- [ WebSocket] ( #websocket )
6867 - [ External WebSocket upgrade] ( #external-websocket-upgrade )
6968- [ Intercept and manipulate requests] ( #intercept-and-manipulate-requests )
@@ -104,15 +103,6 @@ const apiProxy = createProxyMiddleware('/api', { target: 'http://www.example.org
104103
105104(full list of [ ` http-proxy-middleware ` configuration options] ( #options ) )
106105
107- #### createProxyMiddleware(uri [ , config] )
108-
109- ``` javascript
110- // shorthand syntax for the example above:
111- const apiProxy = createProxyMiddleware (' http://www.example.org/api' );
112- ```
113-
114- More about the [ shorthand configuration] ( #shorthand ) .
115-
116106## Example
117107
118108An example with ` express ` server.
@@ -148,6 +138,21 @@ app.use('/api', exampleProxy);
148138app .listen (3000 );
149139```
150140
141+ ### app.use(path, proxy)
142+
143+ If you want to use the server's ` app.use ` ` path ` parameter to match requests;
144+ Create and mount the proxy without the http-proxy-middleware ` context ` parameter:
145+
146+ ``` javascript
147+ app .use (' /api' , createProxyMiddleware ({ target: ' http://www.example.org' , changeOrigin: true }));
148+ ```
149+
150+ ` app.use ` documentation:
151+
152+ - express: http://expressjs.com/en/4x/api.html#app.use
153+ - connect: https://github.com/senchalabs/connect#mount-middleware
154+ - polka: https://github.com/lukeed/polka#usebase-fn
155+
151156## Context matching
152157
153158Providing an alternative way to decide which requests should be proxied; In case you are not able to use the server's [ ` path ` parameter] ( http://expressjs.com/en/4x/api.html#app.use ) to mount the proxy or when you need more flexibility.
@@ -422,47 +427,11 @@ The following options are provided by the underlying [http-proxy](https://github
422427 };
423428 ```
424429
425- ## Shorthand
426-
427- Use the shorthand syntax when verbose configuration is not needed. The ` context ` and ` option.target ` will be automatically configured when shorthand is used. Options can still be used if needed.
428-
429- ``` javascript
430- createProxyMiddleware (' http://www.example.org:8000/api' );
431- // createProxyMiddleware('/api', {target: 'http://www.example.org:8000'});
432-
433- createProxyMiddleware (' http://www.example.org:8000/api/books/*/**.json' );
434- // createProxyMiddleware('/api/books/*/**.json', {target: 'http://www.example.org:8000'});
435-
436- createProxyMiddleware (' http://www.example.org:8000/api' , { changeOrigin: true });
437- // createProxyMiddleware('/api', {target: 'http://www.example.org:8000', changeOrigin: true});
438- ```
439-
440- ### app.use(path, proxy)
441-
442- If you want to use the server's ` app.use ` ` path ` parameter to match requests;
443- Create and mount the proxy without the http-proxy-middleware ` context ` parameter:
444-
445- ``` javascript
446- app .use (' /api' , createProxyMiddleware ({ target: ' http://www.example.org' , changeOrigin: true }));
447- ```
448-
449- ` app.use ` documentation:
450-
451- - express: http://expressjs.com/en/4x/api.html#app.use
452- - connect: https://github.com/senchalabs/connect#mount-middleware
453- - polka: https://github.com/lukeed/polka#usebase-fn
454-
455430## WebSocket
456431
457432``` javascript
458433// verbose api
459434createProxyMiddleware (' /' , { target: ' http://echo.websocket.org' , ws: true });
460-
461- // shorthand
462- createProxyMiddleware (' http://echo.websocket.org' , { ws: true });
463-
464- // shorter shorthand
465- createProxyMiddleware (' ws://echo.websocket.org' );
466435```
467436
468437### External WebSocket upgrade
0 commit comments