diff --git a/docusaurus/docs/proxying-api-requests-in-development.md b/docusaurus/docs/proxying-api-requests-in-development.md index 3fdfb778069..5756fe7596d 100644 --- a/docusaurus/docs/proxying-api-requests-in-development.md +++ b/docusaurus/docs/proxying-api-requests-in-development.md @@ -85,7 +85,7 @@ $ yarn add http-proxy-middleware Next, create `src/setupProxy.js` and place the following contents in it: ```js -const proxy = require('http-proxy-middleware'); +const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = function(app) { // ... @@ -95,16 +95,22 @@ module.exports = function(app) { You can now register proxies as you wish! Here's an example using the above `http-proxy-middleware`: ```js -const proxy = require('http-proxy-middleware'); +const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = function(app) { - app.use( - '/api', - proxy({ + //http requests + app.use('/api', createProxyMiddleware('/api', { target: 'http://localhost:5000', changeOrigin: true, }) ); + //websocket requests + app.use('/ws', createProxyMiddleware('/ws', { + target: 'http://localhost:5000', + changeOrigin: true, + ws: true + }) + ); }; ``` @@ -112,4 +118,4 @@ module.exports = function(app) { > **Note:** This file only supports Node's JavaScript syntax. Be sure to only use supported language features (i.e. no support for Flow, ES Modules, etc). -> **Note:** Passing the path to the proxy function allows you to use globbing and/or pattern matching on the path, which is more flexible than the express route matching. +> **Note:** Passing the path to the createProxyMiddleware function allows you to use globbing and/or pattern matching on the path, which is more flexible than the express route matching.