You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: EXAMPLES.md
+45-4Lines changed: 45 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2895,15 +2895,23 @@ export const auth0 = new Auth0Client({
2895
2895
login: "/login",
2896
2896
logout: "/logout",
2897
2897
callback: "/callback",
2898
-
backChannelLogout: "/backchannel-logout"
2898
+
backChannelLogout: "/backchannel-logout",
2899
+
profile: "/api/me",
2900
+
accessToken: "/api/auth/token"
2899
2901
}
2900
2902
});
2901
2903
```
2902
2904
2903
-
> [!NOTE]
2905
+
> [!NOTE]
2904
2906
> If you customize the login url you will need to set the environment variable `NEXT_PUBLIC_LOGIN_ROUTE` to this custom value for `withPageAuthRequired` to work correctly.
2905
2907
2906
-
To configure the profile and access token routes, you must use the `NEXT_PUBLIC_PROFILE_ROUTE` and `NEXT_PUBLIC_ACCESS_TOKEN_ROUTE`, respectively. For example:
2908
+
#### Configuring routes for client-side usage
2909
+
2910
+
When customizing the `profile` and `accessToken` routes, you need to ensure that client-side functions (`useUser`, `getAccessToken`) and the `Auth0Provider` use the correct routes. There are two approaches:
2911
+
2912
+
**Option 1: Using environment variables (recommended for most cases)**
2913
+
2914
+
Set the environment variables in your `.env.local` file:
> When using `useUser` with a custom route, ensure the `Auth0Provider` is configured with the same `profileRoute` to properly initialize the SWR cache.
2956
+
2957
+
> [!IMPORTANT]
2917
2958
> Updating the route paths will also require updating the **Allowed Callback URLs** and **Allowed Logout URLs** configured in the [Auth0 Dashboard](https://manage.auth0.com) for your client.
0 commit comments