Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 40adc94

Browse files
committed
Move to CRA2 proxy option
http-proxy-middleware is now required for local testing instead of setting "proxy" in package.json Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 2f2413a commit 40adc94

File tree

3 files changed

+80
-9
lines changed

3 files changed

+80
-9
lines changed

dashboard/client/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"bootstrap": "^4.1.3",
1212
"eslint": "^6.4.0",
1313
"eslint-plugin-react": "^7.14.3",
14+
"http-proxy-middleware": "^1.0.6",
1415
"jquery": "^3.5.0",
1516
"moment": "^2.24.0",
1617
"popper.js": "^1.15.0",
@@ -31,14 +32,6 @@
3132
"test": "react-scripts test --env=jsdom",
3233
"eject": "react-scripts eject"
3334
},
34-
"proxy": {
35-
"/api": {
36-
"pathRewrite": {
37-
"^/api": "/"
38-
},
39-
"target": "http://127.0.0.1:8080/function"
40-
}
41-
},
4235
"devDependencies": {},
4336
"browserslist": {
4437
"production": [

dashboard/client/src/setupProxy.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { createProxyMiddleware } = require('http-proxy-middleware');
2+
3+
module.exports = function(app) {
4+
app.use(createProxyMiddleware('/api', {
5+
target: 'http://127.0.0.1:8080/function/',
6+
changeOrigin: true,
7+
pathRewrite: {
8+
'^/api/': '/'
9+
}
10+
}));
11+
};

dashboard/client/yarn.lock

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,13 @@
11411141
version "1.0.0"
11421142
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
11431143

1144+
"@types/http-proxy@^1.17.4":
1145+
version "1.17.4"
1146+
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
1147+
integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==
1148+
dependencies:
1149+
"@types/node" "*"
1150+
11441151
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
11451152
version "2.0.1"
11461153
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff"
@@ -1162,6 +1169,11 @@
11621169
version "7.0.3"
11631170
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
11641171

1172+
"@types/node@*":
1173+
version "14.14.10"
1174+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785"
1175+
integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==
1176+
11651177
"@types/q@^1.5.1":
11661178
version "1.5.2"
11671179
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
@@ -1892,6 +1904,13 @@ braces@^2.3.1, braces@^2.3.2:
18921904
split-string "^3.0.2"
18931905
to-regex "^3.0.1"
18941906

1907+
braces@^3.0.1:
1908+
version "3.0.2"
1909+
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
1910+
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
1911+
dependencies:
1912+
fill-range "^7.0.1"
1913+
18951914
brorand@^1.0.1:
18961915
version "1.1.0"
18971916
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"
@@ -3558,6 +3577,13 @@ fill-range@^4.0.0:
35583577
repeat-string "^1.6.1"
35593578
to-regex-range "^2.1.0"
35603579

3580+
fill-range@^7.0.1:
3581+
version "7.0.1"
3582+
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
3583+
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
3584+
dependencies:
3585+
to-regex-range "^5.0.1"
3586+
35613587
finalhandler@~1.1.2:
35623588
version "1.1.2"
35633589
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
@@ -4117,7 +4143,18 @@ http-proxy-middleware@^0.19.1:
41174143
lodash "^4.17.11"
41184144
micromatch "^3.1.10"
41194145

4120-
http-proxy@^1.17.0:
4146+
http-proxy-middleware@^1.0.6:
4147+
version "1.0.6"
4148+
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.0.6.tgz#0618557722f450375d3796d701a8ac5407b3b94e"
4149+
integrity sha512-NyL6ZB6cVni7pl+/IT2W0ni5ME00xR0sN27AQZZrpKn1b+qRh+mLbBxIq9Cq1oGfmTc7BUq4HB77mxwCaxAYNg==
4150+
dependencies:
4151+
"@types/http-proxy" "^1.17.4"
4152+
http-proxy "^1.18.1"
4153+
is-glob "^4.0.1"
4154+
lodash "^4.17.20"
4155+
micromatch "^4.0.2"
4156+
4157+
http-proxy@^1.17.0, http-proxy@^1.18.1:
41214158
version "1.18.1"
41224159
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
41234160
dependencies:
@@ -4471,6 +4508,11 @@ is-number@^3.0.0:
44714508
dependencies:
44724509
kind-of "^3.0.2"
44734510

4511+
is-number@^7.0.0:
4512+
version "7.0.0"
4513+
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
4514+
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
4515+
44744516
is-obj@^1.0.0, is-obj@^1.0.1:
44754517
version "1.0.1"
44764518
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
@@ -5305,6 +5347,11 @@ lodash.uniq@^4.5.0:
53055347
version "4.17.15"
53065348
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
53075349

5350+
lodash@^4.17.20:
5351+
version "4.17.20"
5352+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
5353+
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
5354+
53085355
loglevel@^1.4.1:
53095356
version "1.6.4"
53105357
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.4.tgz#f408f4f006db8354d0577dcf6d33485b3cb90d56"
@@ -5439,6 +5486,14 @@ micromatch@^3.1.10, micromatch@^3.1.4:
54395486
snapdragon "^0.8.1"
54405487
to-regex "^3.0.2"
54415488

5489+
micromatch@^4.0.2:
5490+
version "4.0.2"
5491+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
5492+
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
5493+
dependencies:
5494+
braces "^3.0.1"
5495+
picomatch "^2.0.5"
5496+
54425497
miller-rabin@^4.0.0:
54435498
version "4.0.1"
54445499
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
@@ -6188,6 +6243,11 @@ performance-now@^2.1.0:
61886243
version "2.1.0"
61896244
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
61906245

6246+
picomatch@^2.0.5:
6247+
version "2.2.2"
6248+
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
6249+
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
6250+
61916251
pify@^2.0.0:
61926252
version "2.3.0"
61936253
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
@@ -8342,6 +8402,13 @@ to-regex-range@^2.1.0:
83428402
is-number "^3.0.0"
83438403
repeat-string "^1.6.1"
83448404

8405+
to-regex-range@^5.0.1:
8406+
version "5.0.1"
8407+
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
8408+
integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
8409+
dependencies:
8410+
is-number "^7.0.0"
8411+
83458412
to-regex@^3.0.1, to-regex@^3.0.2:
83468413
version "3.0.2"
83478414
resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce"

0 commit comments

Comments
 (0)