Feature Request: loginRedirectURL #2257
Closed
jamalsoueidan
started this conversation in
Ideas + Feature Requests
Replies: 1 comment 1 reply
-
Hi @jamalsoueidan I agree that this is confusing and we probably should have a simpler solution. The easiest solution is where ever you provide a link to login, add a <Link to={`/account/login?${new URLSearchParams({return_to: "/some/custom/path"}).toString()}`}>Login</Link> By default if you try to access a route that requires authentication, hydrogen forwards you back to that page after you successfully login. If you'd like to completely customize that, so the user always ends up on the same route after logging in, provide a function customAuthStatusHandler(request: CrossRuntimeRequest) {
if (!request.url) return '/account/login';
return redirect('/some/custom/path');
}
const customerAccount = createCustomerAccountClient({
waitUntil,
request,
session,
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID,
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_API_URL,
customAuthStatusHandler,
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, Is it possible to redirect to a specific URL after logging in? I think some stores would require people to log in before accessing certain features, like blogs or comments, and it would be great to be able to return to that page after logging in.
Beta Was this translation helpful? Give feedback.
All reactions