From 5f41b17defea93b1a84d487231cb090bb3798592 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 6 Jul 2022 17:03:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20cors=20middleware=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/setupProxy.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/setupProxy.js diff --git a/package.json b/package.json index f97de0d..54a2f44 100755 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "formik": "^2.2.9", "framer-motion": "^4.1.13", "history": "^5.2.0", + "http-proxy-middleware": "^2.0.6", "image-to-base64": "^2.2.0", "jsonwebtoken": "^8.5.1", "jwt-decode": "^3.1.2", @@ -95,7 +96,7 @@ "test": "react-scripts test", "eject": "react-scripts eject", "format": "prettier --write .", - "serve" : "serve -s build" + "serve": "serve -s build" }, "eslintConfig": { "extends": [ diff --git a/src/setupProxy.js b/src/setupProxy.js new file mode 100644 index 0000000..bb16be4 --- /dev/null +++ b/src/setupProxy.js @@ -0,0 +1,13 @@ +const { createProxyMiddleware } = require('http-proxy-middleware'); + +module.exports = function (app) { + app.use( + '/api', + createProxyMiddleware({ + target: 'http://localhost:8090', + pathRewrite: { + '^/api': '' + } + }) + ); +};