W
Wasp•3mo ago
cmilazzo

redirect after login

after authenticating with /auth/me the app is redirecting to my landing page, which has a history.push() to go to the logged in dashboard page. However, that means the logged in user can no longer get to the main page. Is there a way to change the default location users are directed to after authentication?
2 Replies
kapa.ai
kapa.ai•3mo ago
Hi @cmilazzo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, Wasp provides a way to specify where the user will be redirected upon successful authentication. This can be done using the onAuthSucceededRedirectTo field in the auth element of your Wasp code. The default value for this field is "/", but you can change it to any route you want. Here is an example of how you can use it:
auth {
methods: ["emailAndPassword"],
onAuthFailedRedirectTo: "/login",
onAuthSucceededRedirectTo: "/your-desired-route"
}
auth {
methods: ["emailAndPassword"],
onAuthFailedRedirectTo: "/login",
onAuthSucceededRedirectTo: "/your-desired-route"
}
In the example above, replace "/your-desired-route" with the route you want your users to be redirected to after successful authentication. Please note that the automatic redirect on successful login only works when using the Wasp-provided Auth UI. For more information, you can refer to the Wasp Auth Overview Documentation (https://wasp-lang.dev/docs/auth/overview#onauthsucceededredirectto-string). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @cmilazzo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
miho
miho•3mo ago
Good bot đź‘Ť

Did you find this page helpful?