Skip to content

Commit 0989f8a

Browse files
committed
feat: Define a global proxy to be used if the instance does not have one
1 parent 3b97619 commit 0989f8a

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,10 @@ AUTHENTICATION_API_KEY=429683C4C977415CAAFCCE10F7D57E11
212212
# If you leave this option as true, the instances will be exposed in the fetch instances endpoint.
213213
AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true
214214
LANGUAGE=en
215+
216+
# Define a global proxy to be used if the instance does not have one
217+
# PROXY_HOST=
218+
# PROXY_PORT=80
219+
# PROXY_PROTOCOL=http
220+
# PROXY_USERNAME=
221+
# PROXY_PASSWORD=

src/api/services/channel.service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,31 @@ export class ChannelStartupService {
338338
}
339339

340340
public async loadProxy() {
341+
this.localProxy.enabled = false;
342+
343+
if (process.env.PROXY_HOST) {
344+
this.localProxy.enabled = true;
345+
this.localProxy.host = process.env.PROXY_HOST;
346+
this.localProxy.port = process.env.PROXY_PORT || '80';
347+
this.localProxy.protocol = process.env.PROXY_PROTOCOL || 'http';
348+
this.localProxy.username = process.env.PROXY_USERNAME;
349+
this.localProxy.password = process.env.PROXY_PASSWORD;
350+
}
351+
341352
const data = await this.prismaRepository.proxy.findUnique({
342353
where: {
343354
instanceId: this.instanceId,
344355
},
345356
});
346357

347-
this.localProxy.enabled = data?.enabled;
348-
this.localProxy.host = data?.host;
349-
this.localProxy.port = data?.port;
350-
this.localProxy.protocol = data?.protocol;
351-
this.localProxy.username = data?.username;
352-
this.localProxy.password = data?.password;
358+
if (data?.enabled) {
359+
this.localProxy.enabled = true;
360+
this.localProxy.host = data?.host;
361+
this.localProxy.port = data?.port;
362+
this.localProxy.protocol = data?.protocol;
363+
this.localProxy.username = data?.username;
364+
this.localProxy.password = data?.password;
365+
}
353366
}
354367

355368
public async setProxy(data: ProxyDto) {

0 commit comments

Comments
 (0)