Skip to content

Commit 05bc5f1

Browse files
author
James Brundage
committed
feat: Start-Htmx ( Fixes #7 )
Only binding to all ports when not in a container
1 parent f7f9168 commit 05bc5f1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Commands/Start-Htmx.ps1

+6-3
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,12 @@ function Start-Htmx {
335335
if (-not $myParams['ServerUrl']) {
336336
$ServerUrl = $myParams['ServerUrl'] =
337337
if (-not $ServerUrl) {
338-
# If we are on unix, and a port has not been set, we will use port 80.
339-
if ($PSVersionTable.Platform -eq 'Unix') {
340-
if (-not $port) { $port = 80}
338+
# If we are on unix, and a port has not been set,
339+
# and an environment variable indicates we are in a container, we will use port 80.
340+
if ($PSVersionTable.Platform -eq 'Unix' -and (
341+
Get-ChildItem env: | Where-Object Name -Match InContainer
342+
)) {
343+
if (-not $port) { $port = 80 }
341344
"http://*:$port/"
342345
} else {
343346
# If we are on Windows, we will use a random port between 4kb and 32kb.

0 commit comments

Comments
 (0)