http-proxy-middleware 패키지 다운
npm install http-proxy-middleware --save
yarn add http-proxy-middleware
react > src폴더 내에 setupProxy.js 파일 추가
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
// 원하는 proxy 설정
};
아래 내용 작성
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
'React' 카테고리의 다른 글
[React] Redux 상태 관리 (0) | 2023.01.26 |
---|---|
[React] Context 상태 관리 (0) | 2023.01.25 |
[React] gh-pages로 깃허브에 퍼블리싱 (0) | 2023.01.09 |
[React] react 이미지 경로 (0) | 2023.01.03 |
[React] state 상태 (0) | 2022.12.30 |