@cloud-cli/px 4.2.7 → 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/proxy-manager.js +10 -13
- package/package.json +1 -1
package/dist/proxy-manager.js
CHANGED
|
@@ -22,13 +22,15 @@ const emptyProxy = {
|
|
|
22
22
|
domain: '',
|
|
23
23
|
target: '',
|
|
24
24
|
cors: false,
|
|
25
|
-
preserveHost:
|
|
25
|
+
preserveHost: true,
|
|
26
26
|
redirect: false,
|
|
27
27
|
redirectUrl: '',
|
|
28
28
|
headers: '',
|
|
29
29
|
authorization: '',
|
|
30
30
|
};
|
|
31
|
-
const readDomain = (options) =>
|
|
31
|
+
const readDomain = (options) => {
|
|
32
|
+
options.domain = options.domain || options.host || options._[0];
|
|
33
|
+
};
|
|
32
34
|
const numberRe = /^[0-9]+$/;
|
|
33
35
|
const readOption = value => {
|
|
34
36
|
switch (true) {
|
|
@@ -123,8 +125,8 @@ export class ProxyManager {
|
|
|
123
125
|
}
|
|
124
126
|
async getProxyListForDomain(options) {
|
|
125
127
|
readDomain(options);
|
|
126
|
-
const all = await this.
|
|
127
|
-
return all.filter((p) => p.domain
|
|
128
|
+
const all = await this.getProxyListWithContainers();
|
|
129
|
+
return all.filter((p) => p.domain.includes(options.domain));
|
|
128
130
|
}
|
|
129
131
|
async reload() {
|
|
130
132
|
const all = await this.getProxyListWithContainers();
|
|
@@ -132,8 +134,8 @@ export class ProxyManager {
|
|
|
132
134
|
for (const t of all) {
|
|
133
135
|
const [domain, path = ""] = t.domain.split("/");
|
|
134
136
|
px.add(new ProxyEntry({
|
|
135
|
-
domain
|
|
136
|
-
path
|
|
137
|
+
domain,
|
|
138
|
+
path,
|
|
137
139
|
target: t.target,
|
|
138
140
|
redirectToHttps: t.redirect,
|
|
139
141
|
redirectToUrl: t.redirectUrl,
|
|
@@ -156,15 +158,10 @@ export class ProxyManager {
|
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
function readProxyFromContainer(c) {
|
|
159
|
-
const domain = [c.labels.host, c.labels.path].join("/");
|
|
161
|
+
const domain = [c.labels.host, c.labels.path].filter(Boolean).join("/");
|
|
160
162
|
const proxyOverrides = get(domain) || {};
|
|
161
163
|
return {
|
|
162
|
-
|
|
163
|
-
redirectUrl: "",
|
|
164
|
-
cors: true,
|
|
165
|
-
authorization: "",
|
|
166
|
-
preserveHost: false,
|
|
167
|
-
headers: "",
|
|
164
|
+
...emptyProxy,
|
|
168
165
|
...proxyOverrides,
|
|
169
166
|
domain,
|
|
170
167
|
target: `http://localhost:${c.ports[0].host}`,
|