Repository navigation
fix(api): allow the PostHog window id header in CORS preflights - #104
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-IDandX-POSTHOG-WINDOW-ID. #98 allowed only the first two, so the preflight refusesX-POSTHOG-WINDOW-ID, the browser never sends the request, and thefetchthrows. In DevTools it shows as provisional headers and 0 B onPOST /api/auth/sign-in/social.X-POSTHOG-WINDOW-IDtoallowHeaders, 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
corsonly 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"listsX-POSTHOG-WINDOW-IDinaccess-control-allow-headers, and Continue with GitHub signs in.