Skip to content

Commit 3501531

Browse files
Make sure console shortcuts use https when http is disabled
Signed-off-by: Phillip Kruger <[email protected]>
1 parent 202338f commit 3501531

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/ide/IdeProcessor.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,20 @@ public void run() {
117117

118118
public static void openBrowser(HttpRootPathBuildItem rp, NonApplicationRootPathBuildItem np, String path, String host,
119119
String port) {
120+
IdeProcessor.openBrowser(rp, np, "http", path, host, port);
121+
}
122+
123+
public static void openBrowser(HttpRootPathBuildItem rp, NonApplicationRootPathBuildItem np, String protocol, String path,
124+
String host,
125+
String port) {
120126
if (path.startsWith("/q")) {
121127
path = np.resolvePath(path.substring(3));
122128
} else {
123129
path = rp.resolvePath(path.substring(1));
124130
}
125131

126-
StringBuilder sb = new StringBuilder("http://");
132+
StringBuilder sb = new StringBuilder(protocol);
133+
sb.append("://");
127134
sb.append(host);
128135
sb.append(":");
129136
sb.append(port);

extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/console/ConsoleProcessor.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,21 @@ void setupConsole(HttpRootPathBuildItem rp, NonApplicationRootPathBuildItem np,
5959
}
6060
Config c = ConfigProvider.getConfig();
6161
String host = c.getOptionalValue("quarkus.http.host", String.class).orElse("localhost");
62-
String port = c.getOptionalValue("quarkus.http.port", String.class).orElse("8080");
62+
boolean isInsecureDisabled = c.getOptionalValue("quarkus.http.insecure-requests", String.class)
63+
.map("disabled"::equals)
64+
.orElse(false);
65+
66+
String port = isInsecureDisabled
67+
? c.getOptionalValue("quarkus.http.ssl-port", String.class).orElse("8443")
68+
: c.getOptionalValue("quarkus.http.port", String.class).orElse("8080");
69+
70+
String protocol = isInsecureDisabled ? "https" : "http";
71+
6372
context.reset(
64-
new ConsoleCommand('w', "Open the application in a browser", null, () -> openBrowser(rp, np, "/", host, port)),
73+
new ConsoleCommand('w', "Open the application in a browser", null,
74+
() -> openBrowser(rp, np, protocol, "/", host, port)),
6575
new ConsoleCommand('d', "Open the Dev UI in a browser", null,
66-
() -> openBrowser(rp, np, "/q/dev-ui", host, port)));
76+
() -> openBrowser(rp, np, protocol, "/q/dev-ui", host, port)));
6777
}
6878

6979
@BuildStep(onlyIf = IsDevelopment.class)

0 commit comments

Comments
 (0)