Skip to content

Commit 04c72a0

Browse files
Improve proxy filter function to prevent infinite loop
1 parent b78d61b commit 04c72a0

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

tools/proxy.conf.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
1-
const filter = function(pathname, req) {
2-
return req.method === 'GET' && pathname.match('^/(index\.html)?$')
3-
};
4-
51
const LOCAL_IP = '127.0.0.1';
62

3+
const backend = [
4+
"/api",
5+
"/storages"
6+
];
7+
78
const PROXY_CONFIG = [
89
{
9-
context: filter,
10+
// don't forward when path matches /static/assets or backend endpoints to prevent infinity loop.
11+
context: function(pathname) {
12+
const ignored = ["/static/assets", ...backend].join("|").replace(/\//g, "\\/");
13+
const matchesIgnored = new RegExp(`^${ignored}`).test(pathname);
14+
return matchesIgnored === false;
15+
},
1016
target: `http://${LOCAL_IP}:4200/static/assets`,
1117
secure: false,
12-
logLevel: "debug"
18+
logLevel: "info"
1319
},
1420
{
15-
context: [
16-
"/api",
17-
"/storages"
18-
],
21+
context: backend,
1922
target: `http://${LOCAL_IP}:48080`,
2023
secure: false,
21-
logLevel: "debug",
24+
logLevel: "info",
2225
changeOrigin: true
2326
}
2427
];
2528

29+
console.log();
30+
console.log('\x1b[35m%s\x1b[0m', 'Note: You need to have a running Strongbox instance for the UI to work!');
31+
console.log("https://strongbox.github.io/developer-guide/building-strongbox-using-strongbox-instance.html#starting-a-strongbox-instance");
32+
console.log();
33+
console.log();
34+
console.log();
35+
2636
module.exports = PROXY_CONFIG;

0 commit comments

Comments
 (0)