#566
fix(proxy): keep HTTPS remembered for unprivileged mode after the proxy stops
Closes #564.
Problem
A proxy started with --unprivileged --https comes back as plain HTTP on port 80 after it stops, whether through portless proxy stop or a SIGTERM. Two things combine:
- Every stop path resets
proxy.tlsbut keepsproxy.unprivileged, so the next start remembers unprivileged mode without the HTTPS that came with it. resolveProxyConfigserves plain HTTP in unprivileged mode unless HTTPS is passed explicitly, and an auto-start passes nothing, so a remembered HTTPS choice was never consulted.
Fix
- The six places that reset the remembered proxy settings (the daemon's exit cleanup and five
proxy stopbranches) now call one helper,resetPersistedProxySettings. It keepsproxy.tlswhileproxy.unprivilegedis set and resets everything else as before. resolveProxyConfigtakespersistedHttps. When unprivileged mode is resumed from the marker rather than requested, the remembered HTTPS choice comes back with it. An explicit--unprivilegedorPORTLESS_UNPRIVILEGED=1without HTTPS still serves plain HTTP, so the no-prompt default is unchanged.
Outside unprivileged mode nothing changes. #563 keeps every remembered setting across an idle exit; this covers an explicit stop and a kill. The two touch the same cleanup block, so whichever lands second needs a small rebase. For pinning the mode per project, #458 lets portless.json set unprivileged and https.
Test plan
cli.test.ts: "keeps HTTPS for unprivileged mode after proxy stop" and "after SIGTERM" start with--unprivileged --https, stop the proxy, check both markers remain, start again with no flags and assert the log has HTTPS listeners and no plain HTTP one. Both fail onmainand pass with the fix. All 13 unprivileged tests pass.pnpm format:check,lint,type-checkandbuildpass.pnpm test: 1212 passed. Failures that also occur onmainon the same machine:certs.test.ts(#429, OpenSSL), themcp.test.ts"rejects every flag" test (5 s timeout under full-suite load, passes alone) andkillOrphanedProcessGroup"does not signal a group leader…" (failed once under load, passes 5 of 5 alone on both this branch andmain).- The steps from #564 on macOS, with a trusted CA, an isolated state directory and no TTY:
| Step | main | This branch |
|---|---|---|
proxy start --unprivileged --https | HTTPS/2 on 443 | HTTPS/2 on 443 |
proxy stop, or SIGTERM to the proxy | proxy.tls removed, proxy.unprivileged kept | Both kept |
portless run auto-starts the proxy | HTTP on 80, app at http://app.localhost | HTTPS/2 on 443 with the port 80 redirect, app at https://app.localhost |
Activity
6vercel[bot]reviewed7d ago
Knat-Devreviewed7d ago
vercel[bot]reviewed7d ago
@Knat-Dev is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.