Fix geolocation not working: dev server was on an insecure origin
Root cause of "won't ask for location permissions": the Geolocation API refuses to run at all on a plain http:// origin (only https:// and localhost count as a "secure context") - Chrome fails immediately with PERMISSION_DENIED before ever showing the actual permission prompt, which is indistinguishable from a real user decline. The dev webapp was served at http://144.76.210.145:5173, so this affected every visitor, not just one browser/device. Fixed by serving the dev server over https:// via a self-signed cert (@vitejs/plugin-basic-ssl, zero config). You'll see a one-time "your connection isn't private" warning in the browser the first time you load it now - click through (Advanced -> Proceed) since it's a self-signed cert; after that geolocation works normally. A real production deploy will need a proper cert via an actual domain name (Let's Encrypt or similar) - self-signed is only acceptable here because we're the ones clicking through our own warning. Also fixed a second, smaller bug found while diagnosing this: the insecure-origin failure was being shown to users as "location access was denied - allow it in your browser settings," which is wrong and unactionable (no browser setting fixes an insecure origin). Nearby.tsx now checks window.isSecureContext upfront and shows an accurate message instead of letting it fail through as a fake permission denial. Verified live: confirmed the exact failure via a real (non-Playwright- granted) browser session hitting the old http:// URL - isSecureContext false, getCurrentPosition immediately erroring with "Only secure origins are allowed" - then confirmed it resolves cleanly over the new https:// URL (isSecureContext true, real geolocation result). 1 new test for the insecure-origin message; 84 webapp + 144 backend tests passing overall. Co-Authored-By:Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
Showing
| ... | @@ -28,6 +28,7 @@ | ... | @@ -28,6 +28,7 @@ |
| "@types/node": "^24.13.3", | "@types/node": "^24.13.3", | ||
| "@types/react": "^19.2.17", | "@types/react": "^19.2.17", | ||
| "@types/react-dom": "^19.2.3", | "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-basic-ssl": "^2.3.0", | |||
| "@vitejs/plugin-react": "^6.0.4", | "@vitejs/plugin-react": "^6.0.4", | ||
| "jsdom": "^29.1.1", | "jsdom": "^29.1.1", | ||
| "oxlint": "^1.75.0", | "oxlint": "^1.75.0", | ||
| ... | ... |
Please
register
or
sign in
to comment