Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend: Bandaid fix for login bug #60

Closed
wants to merge 2 commits into from
Closed

Conversation

alexzhang1618
Copy link
Collaborator

@alexzhang1618 alexzhang1618 commented Jan 10, 2025

There's this bug where even if you successfully login, it doesn't redirect you to the new page (dashboard)

  • I messed around with about 5 million different things but nothing really fixed it
  • The reasoning why is even after setting the user + token cookie, there's a little delay before it becomes available, and the router renavs before the cookies get set, leading to the user getting kicked from the page they want to reroute to
  • I'll annotate below some of the things I tried that didn't work, but the bandaid fix is to just refresh router before pushing
  • also fixing base url because we can detect from VERCEL_URL in deploys, or BASE_URL in development

Copy link

vercel bot commented Jan 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hackathon-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 3:32am

Copy link

Thanks for contributing!
If you've made changes to the API's functionality, please make sure to bump the package
version—see this guide to semantic versioning for details—and
document those changes as appropriate.

const loginResponse = await login(email, password);
setCookie(CookieType.ACCESS_TOKEN, loginResponse.token);
setCookie(CookieType.USER, JSON.stringify(loginResponse.user));
return NextResponse.json(loginResponse);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to make this a NextResponse.redirect(config.api.baseUrl) but that didn't redirect

Comment on lines +41 to 42
router.refresh();
router.push('/');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to set a timeout before pushing but that was finicky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant