Skip to content

Conversation

@pan93412
Copy link
Member

  • refactor: prevent using middleware to improve static route
  • fix(auth): Set the cookie's SameSite policy to "lax"
  • refactor: reduce dynamic routes

Safari's SameSite policy applies throughout the entire session. This means that when we redirect to Google, then back to the callback, and finally to the homepage, the last redirect does not meet the strict SameSite requirements. As a result, the user must log in again.

According to https://datatracker.ietf.org/doc/html/draft-ietf-oauth-browser-based-apps#section-6.1.3.3.1, SameSite can be set to Lax.
@pan93412 pan93412 self-assigned this Sep 29, 2025
@vercel
Copy link

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
admin-frontend Ready Ready Preview Comment Sep 29, 2025 0:44am

@linear
Copy link

linear bot commented Sep 29, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the authentication system to fix the Google login issue by moving from middleware-based authentication to component-based protection and adjusting cookie settings.

  • Removes Next.js middleware for authentication and replaces it with React Server Components
  • Changes cookie SameSite policy from "strict" to "lax" to improve OAuth flow compatibility
  • Refactors login form components into separate modules for better maintainability

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
middleware.ts Completely removes middleware-based authentication
lib/auth.ts Updates cookie SameSite policy from "strict" to "lax"
providers/use-protected-route.tsx Adds new server component for route protection
providers/use-apollo.rsc.tsx Creates authorized Apollo wrapper component
next.config.ts Adds authInterrupts configuration option
components/login-form/ Refactors login form into separate alert components
app/ Updates page components to use new authentication pattern

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pan93412 pan93412 merged commit e93b203 into main Sep 29, 2025
4 checks passed
@pan93412 pan93412 deleted the pan93412/dbp-68-login-頁面需要按兩次-google-登入 branch September 29, 2025 12:45
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.

2 participants