Skip to content

Commit 16795c9

Browse files
committed
add protocol
1 parent ca1a945 commit 16795c9

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

OpenFlow/src/Config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class Config {
2323
public static tls_passphrase: string = Config.getEnv("tls_passphrase", "");
2424
public static port: number = parseInt(Config.getEnv("port", "3000"));
2525
public static domain: string = Config.getEnv("domain", "localhost");
26+
public static protocol: string = Config.getEnv("protocol", "http");
2627
public static saml_issuer: string = Config.getEnv("saml_issuer", "the-issuer");
2728

2829
// public static login_providers:Provider[] = [];
@@ -34,10 +35,16 @@ export class Config {
3435
public static skip_history_collections: string = Config.getEnv("skip_history_collections", "");
3536

3637
public static baseurl(): string {
38+
var result: string = "";
3739
if (Config.tls_crt != '' && Config.tls_key != '') {
38-
return "https://" + Config.domain + ":" + Config.port + "/";
40+
result = "https://" + Config.domain;
41+
} else {
42+
result = Config.protocol + "://" + Config.domain;
43+
}
44+
if (Config.port != 80 && Config.port != 443) {
45+
result = result + ":" + Config.port + "/";
3946
}
40-
return "http://" + Config.domain + ":" + Config.port + "/";
47+
return result;
4148
}
4249
// public static async get_login_providers():Promise<void> {
4350
// this.login_providers = await Config.db.query<Provider>({_type: "provider"}, null, 1, 0, null, "config", TokenUser.rootToken());

OpenFlowNodeRED/src/Config.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class Config {
1818
public static tls_passphrase: string = Config.getEnv("tls_passphrase", "");
1919
public static port: number = parseInt(Config.getEnv("port", "1880"));
2020
public static domain: string = Config.getEnv("domain", "localhost");
21+
public static protocol: string = Config.getEnv("protocol", "http");
2122
public static nodered_domain_schema: string = Config.getEnv("nodered_domain_schema", "");
2223

2324
public static api_ws_url: string = Config.getEnv("api_ws_url", "ws://localhost:3000");
@@ -34,10 +35,20 @@ export class Config {
3435
if (Config.nodered_domain_schema != "") {
3536
Config.domain = Config.nodered_domain_schema.replace("$nodered_id$", Config.nodered_id)
3637
}
38+
// if (Config.tls_crt != '' && Config.tls_key != '') {
39+
// return "https://" + Config.domain + ":" + Config.port + "/";
40+
// }
41+
// return "http://" + Config.domain + ":" + Config.port + "/";
42+
var result: string = "";
3743
if (Config.tls_crt != '' && Config.tls_key != '') {
38-
return "https://" + Config.domain + ":" + Config.port + "/";
44+
result = "https://" + Config.domain;
45+
} else {
46+
result = Config.protocol + "://" + Config.domain;
47+
}
48+
if (Config.port != 80 && Config.port != 443) {
49+
result = result + ":" + Config.port + "/";
3950
}
40-
return "http://" + Config.domain + ":" + Config.port + "/";
51+
return result;
4152
}
4253

4354
public static getEnv(name: string, defaultvalue: string): string {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.167
1+
0.0.168

0 commit comments

Comments
 (0)