add proxy to local env to mimic deploy environment
This commit is contained in:
parent
e3e4b3ccdd
commit
eeaa98fa09
1433
package-lock.json
generated
1433
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,13 @@
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "concurrently -n plugin,webapp,server \"npm --prefix ./plugin run dev\" \"npm --prefix ./webapp run dev\" \"npm --prefix ./server run dev\""
|
||||
"proxy": "node proxy.js",
|
||||
"dev": "concurrently -n plugin,webapp,server,proxy \"npm --prefix ./plugin run dev\" \"npm --prefix ./webapp run dev\" \"npm --prefix ./server run dev\" \"npm run proxy\""
|
||||
},
|
||||
"dependencies": {
|
||||
"concurrently": "^7.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.18.1",
|
||||
"http-proxy-middleware": "^2.0.6"
|
||||
}
|
||||
}
|
||||
|
25
proxy.js
Normal file
25
proxy.js
Normal file
@ -0,0 +1,25 @@
|
||||
const express = require("express");
|
||||
const { createProxyMiddleware } = require("http-proxy-middleware");
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(
|
||||
"/api/",
|
||||
createProxyMiddleware({
|
||||
target: "http://localhost:8080",
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
|
||||
app.use(
|
||||
"/",
|
||||
createProxyMiddleware({
|
||||
target: "http://localhost:3000",
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
|
||||
app.listen(5000);
|
||||
console.log("Reverse proxy listening at http://localhost:5000");
|
||||
|
||||
// http://localhost:3000/api/foo/bar -> http://www.example.org/api/foo/bar
|
Loading…
Reference in New Issue
Block a user