Skip to content

Commit

Permalink
Using the http-proxy-middleware to proxy (#180)
Browse files Browse the repository at this point in the history
* Improve local development CORS handling
* Update proxy to include websocket upgrades
  • Loading branch information
mofojed authored Sep 2, 2021
1 parent 9510515 commit 21663a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/code-studio/.env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
REACT_APP_ENABLE_LOG_PROXY=false
REACT_APP_CORE_API_URL=http://localhost:10000/jsapi
REACT_APP_NOTEBOOKS_URL=http://localhost:10000/notebooks
REACT_APP_LAYOUTS_URL=http://localhost:10000/layouts

# Proxy set in src/setupProxy.js to handle CORS for other URLs
# https://create-react-app.dev/docs/proxying-api-requests-in-development/

REACT_APP_ROUTER_BASE_NAME=/
REACT_APP_INTERNAL_PLUGINS=ExamplePlugin
PORT=4000
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"cross-env": "^7.0.2",
"deep-equal": "^2.0.4",
"fira": "github:mozilla/fira#4.202",
"http-proxy-middleware": "^2.0.1",
"jquery": "^3.5.1",
"jszip": "3.2.2",
"lodash.clamp": "^4.0.3",
Expand Down
10 changes: 10 additions & 0 deletions packages/code-studio/src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = app => {
app.use(
createProxyMiddleware({
target: 'http://localhost:10000',
ws: true,
})
);
};

0 comments on commit 21663a2

Please sign in to comment.