• Aryan Noshirvnai's avatar
    Fix geolocation not working: dev server was on an insecure origin · b2c5ae5b
    Aryan Noshirvnai authored
    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: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
    b2c5ae5b
Nearby.test.tsx 11.3 KB