Skip to content

fix: use NEXT_PUBLIC_PROFILE_ROUTE in Auth0Provider#2021

Merged
tusharpandey13 merged 2 commits intomainfrom
bugfix/1965-20250401141309
Apr 1, 2025
Merged

fix: use NEXT_PUBLIC_PROFILE_ROUTE in Auth0Provider#2021
tusharpandey13 merged 2 commits intomainfrom
bugfix/1965-20250401141309

Conversation

@tusharpandey13
Copy link
Contributor

@tusharpandey13 tusharpandey13 commented Apr 1, 2025

Duplicate of #1966, thanks @seanparmelee

📋 Changes

Similar to what's done in useUser, first check process.env.NEXT_PUBLIC_PROFILE_ROUTE and fallback to "/auth/profile" when setting the fallback data for the profile route.

📎 References

Fixes #1965

🎯 Testing

  1. Configure a custom profile route via the NEXT_PUBLIC_PROFILE_ROUTE environment variable. (ex: NEXT_PUBLIC_PROFILE_ROUTE=/api/me.
  2. In a server component, fetch a user and pass it to the Auth0Provider:
const session = await auth0.getSession();

...

return (
  <Auth0Provider user={session?.user}>
    {children}
  </Auth0Provider>
);
  1. In a child client component, use the useUser() hook to retrieve the user and render a field, such as the sub:
const user = userUser()

...

return (
  <div>User: {user?.sub || 'undefined'}</div>
);
  1. Log into your application and navigate to a page that uses the component from the previous step.
  2. Confirm that the logged-in user's sub is immediately visible on the screen and that there isn't a brief period where "undefined" is first shown.

@tusharpandey13 tusharpandey13 requested a review from a team as a code owner April 1, 2025 08:54
@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.63%. Comparing base (4cce952) to head (75b11cf).

Files with missing lines Patch % Lines
src/client/providers/auth0-provider.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2021   +/-   ##
=======================================
  Coverage   74.63%   74.63%           
=======================================
  Files          21       21           
  Lines        1849     1849           
  Branches      283      283           
=======================================
  Hits         1380     1380           
  Misses        462      462           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tusharpandey13 tusharpandey13 merged commit 40229fb into main Apr 1, 2025
12 checks passed
@tusharpandey13 tusharpandey13 deleted the bugfix/1965-20250401141309 branch April 1, 2025 09:01
@tusharpandey13 tusharpandey13 mentioned this pull request Apr 1, 2025
@tusharpandey13 tusharpandey13 changed the title rebase onto contributors commit fix: use NEXT_PUBLIC_PROFILE_ROUTE in Auth0Provider Apr 1, 2025
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.

Auth0Provider user is not used when a custom profile route is set

4 participants