Skip to content

fix(api): allow the PostHog window id header in CORS preflights - #104

Merged
brgv-code merged 1 commit into
mainfrom
fix/api-cors-posthog-window-id
Nov 3, 2026
Merged

brgv-code merged 1 commit into
mainfrom
fix/api-cors-posthog-window-id

Conversation

@brgv-code

Copy link
Copy Markdown
Owner

Sign in fails with "Could not reach the server" for anyone who accepted analytics.

Once consent is given, posthog-js adds three headers to calls to api.jlog.ai: X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID and X-POSTHOG-WINDOW-ID. #98 allowed only the first two, so the preflight refuses X-POSTHOG-WINDOW-ID, the browser never sends the request, and the fetch throws. In DevTools it shows as provisional headers and 0 B on POST /api/auth/sign-in/social.

  • Adds X-POSTHOG-WINDOW-ID to allowHeaders, and corrects the comment that called them a pair.

No test: the API tests have no harness that boots the full app, and Hono's cors only echoes the list back, so a test would only assert that a constant contains a string.

Check after merging: with analytics accepted, curl -si -X OPTIONS https://api.jlog.ai/api/auth/sign-in/social -H "Origin: https://jlog.ai" -H "Access-Control-Request-Method: POST" lists X-POSTHOG-WINDOW-ID in access-control-allow-headers, and Continue with GitHub signs in.

@brgv-code
brgv-code merged commit 75d5d82 into main Nov 3, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant