diff --git a/settings/authentication-personalization/authentication-setup/jwt.mdx b/settings/authentication-personalization/authentication-setup/jwt.mdx index d35fd7e3a..9bd212600 100644 --- a/settings/authentication-personalization/authentication-setup/jwt.mdx +++ b/settings/authentication-personalization/authentication-setup/jwt.mdx @@ -100,3 +100,20 @@ async def return_mintlify_auth_status(current_user): return RedirectResponse(url=f'https://docs.foo.com/login/jwt-callback#{jwt_token}', status_code=302) ``` + +## Redirecting Unauthenticated Users + +When an unauthenticated user tries to access a specific page, Mintlify preserves their intended destination through a redirect flow: + +1. The user attempts to visit a certain page (e.g., `/quickstart`) + +2. Mintlify redirects them to your login URL and adds the (relative) original destination as a `redirect` query parameter + +Example: + +* Original request: [`https://docs.foo.com/quickstart`](https://docs.foo.com/quickstart) + +* Redirect to login: [`https://foo.com/docs-login?redirect=%2Fquickstart`](https://foo.com/docs-login?redirect=%2Fquickstart) + +After successful authentication, you can include this same `redirect` parameter in your JWT callback URL to send users to their intended destination: +`https://docs.foo.com/login/jwt-callback?redirect=%2Fquickstart#{SIGNED_JWT}`