Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 466defc

Browse files
committed
feat: add --auth argument for code-server authentication (password|none)
1 parent 1b6b894 commit 466defc

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

scripts/serve.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* pnpm serve # Build, install, and start code-server on port 9080
1212
* pnpm serve -- --port 8080 # Use a custom port
1313
* pnpm serve -- --host 0.0.0.0 # Bind to all interfaces (for Docker/remote access)
14+
* pnpm serve -- --auth none # Disable authentication (password|none)
1415
* pnpm serve:rebuild # Only rebuild and reinstall the extension
1516
*
1617
* The script will:
@@ -66,6 +67,16 @@ function getHost() {
6667
}
6768
const host = getHost()
6869

70+
// Parse --auth argument (optional, passed to code-server: "password" or "none")
71+
function getAuth() {
72+
const authIndex = process.argv.indexOf("--auth")
73+
if (authIndex !== -1 && process.argv[authIndex + 1]) {
74+
return process.argv[authIndex + 1]
75+
}
76+
return null
77+
}
78+
const auth = getAuth()
79+
6980
function log(message) {
7081
console.log(`${CYAN}[serve]${RESET} ${message}`)
7182
}
@@ -175,28 +186,29 @@ async function main() {
175186
console.log(`\n${BOLD}Starting code-server...${RESET}`)
176187
console.log(` Working directory: ${cwd}`)
177188
console.log(` URL: ${CYAN}http://${host}:${port}${RESET}`)
178-
console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`)
189+
if (auth === "none") {
190+
console.log(` Auth: ${YELLOW}disabled${RESET}`)
191+
} else {
192+
console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`)
193+
}
179194
console.log(`\n Press ${BOLD}Ctrl+C${RESET} to stop\n`)
180195

181196
// Spawn code-server with:
197+
// --bind-addr: Address to bind to
198+
// --auth: Authentication type (password or none)
182199
// --disable-workspace-trust: Skip workspace trust prompts
183200
// --disable-getting-started-override: Disable welcome/getting started page
184201
// -e: Ignore last opened directory (start fresh)
185-
const codeServer = spawn(
186-
"code-server",
187-
[
188-
"--bind-addr",
189-
`${host}:${port}`,
190-
"--disable-workspace-trust",
191-
"--disable-getting-started-override",
192-
"-e",
193-
cwd,
194-
],
195-
{
196-
stdio: "inherit",
197-
cwd: cwd,
198-
},
199-
)
202+
const args = ["--bind-addr", `${host}:${port}`]
203+
if (auth) {
204+
args.push("--auth", auth)
205+
}
206+
args.push("--disable-workspace-trust", "--disable-getting-started-override", "-e", cwd)
207+
208+
const codeServer = spawn("code-server", args, {
209+
stdio: "inherit",
210+
cwd: cwd,
211+
})
200212

201213
codeServer.on("error", (err) => {
202214
logError(`Failed to start code-server: ${err.message}`)

0 commit comments

Comments
 (0)