feat(proxy): add x-current-path header for admin routing and update P… - #2149
Merged
Conversation
…ostHog provider logic - Introduced x-current-path header in proxy responses for better path tracking. - Updated RootLayout to determine if the request is for an admin page based on the x-current-path header. - Enhanced WithPostHogIdentifier to conditionally load Auth0 user based on admin request status. - Added unit tests to verify the new behavior for admin page handling and PostHog integration.
Takaros999
approved these changes
Jul 24, 2026
| // from `web/proxy.ts` to framework and page scripts. | ||
| await headers(); | ||
| const requestHeaders = await headers(); | ||
| const currentPath = requestHeaders.get("x-current-path"); |
Contributor
There was a problem hiding this comment.
im curious if in nextjs using this header is the most reliable way for reading the path
Contributor
Author
|
|
||
| <Auth0Provider> | ||
| <WithPostHogIdentifier> | ||
| <WithPostHogIdentifier isAdminRequest={isAdminRequest}> |
Contributor
There was a problem hiding this comment.
i found the naming very confusing. Conceptually we're trying to disable the posthog provider for admin routes.
I feel like we should either have a disable=boolean prop in posthog provider or in this file hide conditionally based on the admin routes
eg.
<WithPostHogIdentifier disable={isAdminRequest}>
…dentification prop - Replaced isAdminRequest with disableUserIdentification in WithPostHogIdentifier for clearer intent. - Adjusted RootLayout to reflect the new prop and updated related logic. - Modified unit tests to ensure compatibility with the new prop structure.
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.
PR Type
Description
This PR prevents admin pages from periodically requesting Auth0
/api/auth/profileand receiving401responses. Admin pages use separate authentication, but the global PostHog provider previously mounted Auth0useUser()for every route./admin.Tested with:
pnpm exec jest tests/unit/root-posthog-provider.test.tsx tests/unit/proxy-auth-origin.test.ts --runInBand— 29 tests passed.Checklist