Add middleware proxy on dev

This commit is contained in:
Simponic 2023-01-18 10:07:40 -07:00
parent d1059a9c55
commit e33c52f97b
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 52B3774857EB24B1
3 changed files with 15 additions and 0 deletions

View File

@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"http-proxy-middleware": "^2.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.2",

View File

@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"http-proxy-middleware": "^2.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.2",

13
front/src/setupProxy.js Normal file
View File

@ -0,0 +1,13 @@
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
if (process.env.NODE_ENV != 'production') {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:8080',
changeOrigin: true,
})
);
}
};