인프런에서
<따라하며 배우는 노드, 리액트 시리즈 - 기본 강의> 중 22강을 듣다가
강의 영상대로 똑같이 따라했는데 뭔가 다른 에러발생..!!
Starting the development server...
(node:17907) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:17907) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
crbug/1173575, non-JS module files deprecated.
강의가 자주 업데이트 되는게 아니다보니까 최신버전과 다른 부분들이 있어서 그런듯
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
proxy({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
<수정 후>
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
[참고]
리액트 공식 문서
https://create-react-app.dev/docs/proxying-api-requests-in-development/#configuring-the-proxy-manually