Conversation
Signed-off-by: ruo <ruoliu.dev@gmail.com>
Signed-off-by: ruo <ruoliu.dev@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an authentication issue where the /mail route incorrectly redirected authenticated users to /auth due to the Next.js server not receiving the session cookie from the Railway API origin. The solution involves shifting the authentication responsibility for the /mail page to the client-side, allowing it to bootstrap authentication from the client API session, similar to the /calendar route. This change ensures that authenticated users can access the mail page without unexpected redirects. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an authentication issue on the /mail route caused by cross-origin cookies. The fix involves removing the server-side authentication check and redirect, and instead relying on the client-side to manage the authentication session. This aligns the /mail route's behavior with what is described as the existing behavior for the /calendar route. The server-side data prefetching is now treated as a best-effort operation. The changes are correct and effectively resolve the issue by adopting a common pattern for handling authentication in applications with a separate frontend and backend.
There was a problem hiding this comment.
Pull request overview
Removes the server-side auth redirect from the /mail route so authenticated users aren’t incorrectly bounced to /auth when the session cookie lives on the API origin (cross-origin). This aligns /mail with the existing client-bootstrapped auth flow already used by the mail UI (and described as matching /calendar behavior).
Changes:
- Removed the server-side
redirectIfUnauthenticated()call fromMailPage. - Removed the now-unneeded
redirectIfUnauthenticatedimport. - Kept server-side prefetch of session/thread data as best-effort (nullable) bootstrapping.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
Root cause
Production auth uses a session cookie on the Railway API origin. The Vercel Next server does not receive that cookie, so any /mail redirect based on Next server cookies or a server-side auth probe will incorrectly send authenticated users back to /auth. That is why auth/session and calendar worked, but /mail flashed and bounced.
Validation