-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetupProxy.js
52 lines (48 loc) · 1.48 KB
/
setupProxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require("express");
let cors = require("cors");
const { createProxyMiddleware } = require("http-proxy-middleware");
let sessionCookie = "";
const onProxyReq = (proxyReq) => {
if (sessionCookie) {
proxyReq.setHeader("cookie", sessionCookie);
}
};
const onProxyRes = (proxyRes) => {
const proxyCookie = proxyRes.headers["set-cookie"];
if (proxyCookie) {
sessionCookie = proxyCookie;
}
};
// proxy middleware options
const options = {
//target: "https://eidsr.health.go.ug",
// target: "https://dev.ndpme.go.ug/ndpdb",
// target: "http://localhost:8080",
// target: "https://tests.dhis2.hispuganda.org/hmis/",
// target: "https://hmis.health.go.ug",
// target: "https://hmis-tests.health.go.ug",
// target: "https://tests.dhis2.stephocay.com/sia",
// target: "https://etracker.moh.gov.rw/individualrecords",
target: "https://epivac.health.go.ug",
// target: "https://train.ndpme.go.ug/ndpdb",
// target: "https://play.im.dhis2.org/dev",
// target: "https://emisuganda.org/emis",
// target: "https://dev.emisuganda.org/emisdev",
// target: "https://play.dhis2.org/40.3.0",
onProxyReq,
onProxyRes,
changeOrigin: true, // needed for virtual hosted sites
auth: undefined,
logLevel: "debug",
};
// create the proxy (without context)
const exampleProxy = createProxyMiddleware(options);
const app = express();
app.use(
cors({
credentials: true,
origin: ["http://localhost:3000"],
})
);
app.use("/", exampleProxy);
app.listen(3002);