Description
Currently, when an unauthenticated user tries to click on a restricted action inside the /courses or portal section (like tracking path progress or viewing locked content), the route guard intercepts the request but fails to preserve the initial destination state (intended target URL).
Instead of redirecting the user back to the exact course page they were viewing after a successful login, the application defaults back to the homepage (/). This ruins the user experience as they have to manually search for the course again.
Steps to Reproduce
- Log out of the platform (or use Incognito).
- Go directly to a specific course detail page or syllabus overview section.
- Click an action that triggers the authorization barrier (Login modal/page).
- Complete the sign-in/auth flow successfully.
- Notice that you are dropped on the main root landing page (
/) instead of being seamlessly redirected back to the course page you intended to explore.
Technical Analysis & Solution
The current authentication hook/middleware is just calling router.push('/') upon a successful login event without checking for an active callback or redirectTo parameter inside the state/query strings.
- Fix: Intercept the initial route path using Next.js routing query string (e.g.,
/login?callbackUrl=/courses/nextjs-deep-dive).
- Result: After authentication finishes, dynamically parse the
callbackUrl search param and route the user seamlessly back to their intended dashboard, establishing standard enterprise-grade route guarding.
Please assign this to me.
Description
Currently, when an unauthenticated user tries to click on a restricted action inside the
/coursesor portal section (like tracking path progress or viewing locked content), the route guard intercepts the request but fails to preserve the initial destination state (intended target URL).Instead of redirecting the user back to the exact course page they were viewing after a successful login, the application defaults back to the homepage (
/). This ruins the user experience as they have to manually search for the course again.Steps to Reproduce
/) instead of being seamlessly redirected back to the course page you intended to explore.Technical Analysis & Solution
The current authentication hook/middleware is just calling
router.push('/')upon a successful login event without checking for an active callback orredirectToparameter inside the state/query strings./login?callbackUrl=/courses/nextjs-deep-dive).callbackUrlsearch param and route the user seamlessly back to their intended dashboard, establishing standard enterprise-grade route guarding.Please assign this to me.