mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-02-09 20:58:10 -05:00
fix #290
This commit is contained in:
parent
3de62eb70d
commit
14d1879ccd
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
const { createProxyMiddleware } = require("http-proxy-middleware");
|
const { createProxyMiddleware } = require("http-proxy-middleware");
|
||||||
|
|
||||||
|
const target = process.env.PROXY_TARGET || "http://localhost:8080/";
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
app.use(
|
app.use(
|
||||||
"/api",
|
"/api",
|
||||||
@ -13,7 +15,7 @@ module.exports = (app) => {
|
|||||||
// Note: the `/api` here seems redundant with that above, but without it, the
|
// Note: the `/api` here seems redundant with that above, but without it, the
|
||||||
// `ws: true` here appears to break react-script's automatic websocket reloading.
|
// `ws: true` here appears to break react-script's automatic websocket reloading.
|
||||||
createProxyMiddleware("/api", {
|
createProxyMiddleware("/api", {
|
||||||
target: process.env.PROXY_TARGET || "http://localhost:8080/",
|
target,
|
||||||
ws: true,
|
ws: true,
|
||||||
|
|
||||||
// XXX: this doesn't appear to work for websocket requests. See
|
// XXX: this doesn't appear to work for websocket requests. See
|
||||||
@ -38,6 +40,13 @@ module.exports = (app) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// The `changeOrigin` above doesn't appear to apply to WebSocket requests.
|
||||||
|
// This has a similar effect.
|
||||||
|
// <https://github.com/scottlamb/moonfire-nvr/issues/290>
|
||||||
|
onProxyReqWs: (proxyReq, req, socket, options, head) => {
|
||||||
|
proxyReq.setHeader("origin", target);
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user