In my next.js app. I want to redirect the user to the current page after login.
I’m not sure how to do that. So far I only figured out how to redirect user to a specific page using the following code:
import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';
// Redirect all users who just logged in to /build
export default handleAuth({
async login(req, res) {
await handleLogin(req, res, {
returnTo: "/STATIC_PAGE",
});
},
});
This won’t work because I don’t know the specific page the current user is viewing hence I can’t always redirect them to a static page. Any help is appreciated.