Skip to content

Commit

Permalink
fix:set a http proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jundm committed Apr 24, 2022
1 parent 7721b4a commit 66d0d98
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 100 deletions.
78 changes: 23 additions & 55 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dayjs": "^1.10.7",
"detect-browser": "^5.3.0",
"formik": "^2.2.9",
"http-proxy-middleware": "^2.0.6",
"http-proxy": "^1.18.1",
"isbot": "^3.4.2",
"next": "latest",
"next-redux-wrapper": "^7.0.5",
Expand All @@ -38,6 +38,7 @@
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "13.5.0",
"@types/http-proxy": "^1.17.8",
"@types/react": "17.0.38",
"@types/redux-logger": "^3.0.9",
"autoprefixer": "^10.4.2",
Expand Down
13 changes: 13 additions & 0 deletions frontend/pages/api/proxy/[...path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { IncomingMessage, ServerResponse } from "http";
import httpProxy from "http-proxy";
const API_URL = process.env.NEXT_PUBLIC_ENV_BASE_URL; // The actual URL of your API
const proxy = httpProxy.createProxyServer();
// Make sure that we don't parse JSON bodies on this route:
export const config = {
api: {
bodyParser: false,
},
};
export default (req: IncomingMessage, res: ServerResponse) => {
proxy.web(req, res, { target: API_URL, changeOrigin: true });
};
26 changes: 0 additions & 26 deletions frontend/pages/api/proxy/[...slug].ts

This file was deleted.

20 changes: 2 additions & 18 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@
"@types/qs" "*"
"@types/range-parser" "*"

"@types/express@*", "@types/express@^4.17.13":
"@types/express@*":
"integrity" "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA=="
"resolved" "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz"
"version" "4.17.13"
Expand Down Expand Up @@ -3645,17 +3645,6 @@
"agent-base" "6"
"debug" "4"

"http-proxy-middleware@^2.0.6":
"integrity" "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw=="
"resolved" "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz"
"version" "2.0.6"
dependencies:
"@types/http-proxy" "^1.17.8"
"http-proxy" "^1.18.1"
"is-glob" "^4.0.1"
"is-plain-obj" "^3.0.0"
"micromatch" "^4.0.2"

"http-proxy@^1.18.1":
"integrity" "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ=="
"resolved" "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz"
Expand Down Expand Up @@ -3863,11 +3852,6 @@
"resolved" "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz"
"version" "7.0.0"

"is-plain-obj@^3.0.0":
"integrity" "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA=="
"resolved" "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz"
"version" "3.0.0"

"is-potential-custom-element-name@^1.0.1":
"integrity" "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ=="
"resolved" "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz"
Expand Down Expand Up @@ -4652,7 +4636,7 @@
"resolved" "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz"
"version" "1.4.1"

"micromatch@^4.0.2", "micromatch@^4.0.4":
"micromatch@^4.0.4":
"integrity" "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg=="
"resolved" "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz"
"version" "4.0.4"
Expand Down

1 comment on commit 66d0d98

@vercel
Copy link

@vercel vercel bot commented on 66d0d98 Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.