1010 * Usage:
1111 * pnpm serve # Build, install, and start code-server on port 9080
1212 * pnpm serve -- --port 8080 # Use a custom port
13+ * pnpm serve -- --host 0.0.0.0 # Bind to all interfaces (for Docker/remote access)
1314 * pnpm serve:rebuild # Only rebuild and reinstall the extension
1415 *
1516 * The script will:
@@ -54,6 +55,17 @@ function getPort() {
5455}
5556const port = getPort ( )
5657
58+ // Parse --host argument (default: 127.0.0.1, use 0.0.0.0 for Docker/remote access)
59+ const DEFAULT_HOST = "127.0.0.1"
60+ function getHost ( ) {
61+ const hostIndex = process . argv . indexOf ( "--host" )
62+ if ( hostIndex !== - 1 && process . argv [ hostIndex + 1 ] ) {
63+ return process . argv [ hostIndex + 1 ]
64+ }
65+ return DEFAULT_HOST
66+ }
67+ const host = getHost ( )
68+
5769function log ( message ) {
5870 console . log ( `${ CYAN } [serve]${ RESET } ${ message } ` )
5971}
@@ -162,7 +174,7 @@ async function main() {
162174 const cwd = process . cwd ( )
163175 console . log ( `\n${ BOLD } Starting code-server...${ RESET } ` )
164176 console . log ( ` Working directory: ${ cwd } ` )
165- console . log ( ` URL: ${ CYAN } http://127.0.0.1 :${ port } ${ RESET } ` )
177+ console . log ( ` URL: ${ CYAN } http://${ host } :${ port } ${ RESET } ` )
166178 console . log ( ` Password: ${ YELLOW } ~/.config/code-server/config.yaml${ RESET } ` )
167179 console . log ( `\n Press ${ BOLD } Ctrl+C${ RESET } to stop\n` )
168180
@@ -174,7 +186,7 @@ async function main() {
174186 "code-server" ,
175187 [
176188 "--bind-addr" ,
177- `127.0.0.1 :${ port } ` ,
189+ `${ host } :${ port } ` ,
178190 "--disable-workspace-trust" ,
179191 "--disable-getting-started-override" ,
180192 "-e" ,
0 commit comments