:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(dev): enable strictPort on vite dev server (#62976)
Raúl Negrón-Oterodc9c31acbcb7
diff --git a/bin/start-frontend b/bin/start-frontendindex 389b537b36f1..b2efcc1cf482 100755--- a/bin/start-frontend+++ b/bin/start-frontend@@ -28,10 +28,11 @@ vite_port_listeners() {return 0}-# Vite isn't configured with strictPort, so if a stale process from a previous-# session is still squatting on $VITE_PORT, Vite silently falls back to the next-# free port — and the app, which hardcodes $VITE_PORT everywhere, fails to load.-# Reclaim the port up front so we always come up where we're expected.+# If a stale process from a previous session is still squatting on $VITE_PORT,+# the app — which hardcodes $VITE_PORT everywhere — fails to load. Reclaim the+# port up front so we always come up where we're expected; Vite's strictPort+# turns any reclaim failure into a loud startup error instead of a silent+# fallback to the next free port.free_vite_port() {local pidspids=$(vite_port_listeners)diff --git a/frontend/vite.config.mts b/frontend/vite.config.mtsindex ad563eef1f89..5436d599a512 100644--- a/frontend/vite.config.mts+++ b/frontend/vite.config.mts@@ -105,6 +105,10 @@ export default defineConfig(({ mode }) => {},server: {port: 8234,+ // The rest of the stack hardcodes 8234, so falling back to another port serves a+ // broken app (the browser keeps talking to whatever squats 8234). Fail loudly instead;+ // bin/start-frontend reclaims the port from stale processes before launching.+ strictPort: true,host: process.argv.includes('--host') ? '0.0.0.0' : 'localhost',allowedHosts: process.env.VITE_ALLOWED_HOSTS?.split(',').map((s) => s.trim())