© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
user8923

withPageAuth redirectTo, how to go back to previous page after login?

export const getServerSideProps = withPageAuth({ redirectTo: ("/login") });
export const getServerSideProps = withPageAuth({ redirectTo: ("/login") });

After authentication in the /login page, I can't figure out how to route back to the previous page. I don't want to have to manually add a "referrer" query parameter in the redirectTo field, and I also want the ability to include any possible query params or anchors that existed in the previous page's URL. I can't use router.back() because apparently the redirection to the login page uses router.replace(), which doesn't write to browser history. Kinda stumped on this one!
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

withPageAuth Dynamic Page
SupabaseSSupabase / help-and-questions
4y ago
withPageAuth redirects back right after sign in?
SupabaseSSupabase / help-and-questions
4y ago
Can't go back to the Dashboard after upgrading
SupabaseSSupabase / help-and-questions
5mo ago
Permission based withPageAuth
SupabaseSSupabase / help-and-questions
4y ago