본문 바로가기
개발(라이브러리,프레임워크)/react.js & react native

devServer proxy 설정

by zieunee 2022. 2. 6.
반응형

https://create-react-app.dev/docs/proxying-api-requests-in-development

 

Proxying API Requests in Development | Create React App

Note: this feature is available with react-scripts@0.2.3 and higher.

create-react-app.dev

npm install http-proxy-middleware --save
//setupProxy.js
const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function (app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: process.env.REACT_APP_PROD_BASE_DOMAIN,
      changeOrigin: true,
    }),
  );
  app.use(
    '/gw',
    createProxyMiddleware({
      target: process.env.REACT_APP_PROD_EGW_DOMAIN,
      changeOrigin: true,
    }),
  );
};
반응형

'개발(라이브러리,프레임워크) > react.js & react native' 카테고리의 다른 글

ThemeProvider(styled-components)  (0) 2022.06.07
memoization  (0) 2022.05.22
eject 대신 webpack설치하기  (0) 2022.02.05
redux-promise-middleware  (0) 2022.02.04
redux-thunk  (0) 2022.02.03