Skip to content

Commit

Permalink
Make Quarkus listen on all interfaces in WSL dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 18, 2022
1 parent 60bc5e6 commit bbf947b
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ public String getValue(String propertyName) {
// in remote-dev mode we need to listen on all interfaces
return ALL_INTERFACES;
}
return LaunchMode.current().isDevOrTest() ? "localhost" : ALL_INTERFACES;
// In dev-mode we want to only listen on localhost so others on the network cannot connect to the application.
// However, in WSL this would result in the application not being accessible,
// so in that case, we launch it on all interfaces.
return (LaunchMode.current().isDevOrTest() && !isWSL()) ? "localhost" : ALL_INTERFACES;
}
return null;
}

/**
* @return {@code true} if the application is running in a WSL (Windows Subsystem for Linux) environment
*/
private boolean isWSL() {
var sysEnv = System.getenv();
return sysEnv.containsKey("IS_WSL") || sysEnv.containsKey("WSL_DISTRO_NAME");
}

@Override
public String getName() {
return "Quarkus HTTP Host Default Value";
Expand Down

0 comments on commit bbf947b

Please sign in to comment.