From 8eed59be105998185518833e5e8211627d8ce886 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 6 Jul 2022 17:31:16 +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 --- src/setupProxy.js | 14 ++++++++++++++ src/utils/axios.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/setupProxy.js diff --git a/src/setupProxy.js b/src/setupProxy.js new file mode 100644 index 0000000..982babe --- /dev/null +++ b/src/setupProxy.js @@ -0,0 +1,14 @@ +const { createProxyMiddleware } = require('http-proxy-middleware'); + +module.exports = function (app) { + app.use( + '/api', + createProxyMiddleware({ + target: 'http://localhost:8090', + changeOrigin: true, + pathRewrite: { + '^/api': '' + } + }) + ); +}; diff --git a/src/utils/axios.js b/src/utils/axios.js index 171e868..baefa5c 100755 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -8,7 +8,7 @@ import Swal from 'sweetalert2'; const axiosService = axios.create({ // baseURL: process.env.NODE_ENV === 'development' ? process.env.REACT_APP_API_URL : '', baseURL: process.env.REACT_APP_API_URL, - withCredentials: process.env.NODE_ENV !== 'production', // 개발시만 사용 : crossdomain + withCredentials: true, // process.env.NODE_ENV !== 'production', // 개발시만 사용 : crossdomain timeout: Number(process.env.REACT_APP_SERVER_TIMEOUT), headers: { 'Content-Type': 'application/json'