How can I redirect back to an originally requested page after login?

Hi, I am currently adding auth to a nextjs app and using the nextjs sample app as a starting point. In that app, you have a hardcoded redirect to a profile page after login. However, I’d want to be able to redirect a user back to whatever protected page they originally were trying to access. How can I pass in that path? I tried passing it as a query param in the redirect url but that resulted in an error. Searched the docs but did not see anything. Any insight or advice would be appreciated!

Also, on a possibly unrelated note, why is the authenticate logic on a client-side webpage? Is it possible to move that logic to the server?

Nvm, found the answer, didn’t realize I also needed to include that query param in the redirect url set in the dashboard, which makes total sense.

Heya Anders,

Glad you got it figured out!

For anyone else that makes it here, you can read about how to do this in the redirect section in our Docs: https://stytch.com/docs/home#resources_redirect-urls