chore: update currentURL - #78
Conversation
Fix login redirect after session expiry (preserve original path)
…irect-logic Preserve full path when redirecting to login
There was a problem hiding this comment.
Pull request overview
Removes the dedicated VITE_REDIRECT_URL configuration and updates the frontend auth flow to preserve/restore the user’s current path via a safe redirect query parameter.
Changes:
- Removed
VITE_REDIRECT_URLfrom setup types/loader, generated.envfiles, examples, and GitHub Actions workflows. - Added safe redirect parsing + callback URL building utilities (
getRedirectPath,buildCallbackURL). - Updated SessionCheck/Login/Header/SocialLink to use
VITE_CLIENT_URLand theredirectquery param for post-auth navigation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| setup/src/types.ts | Drops viteRedirectUrl from FrontendConfig. |
| setup/src/index.ts | Stops writing VITE_REDIRECT_URL into the frontend .env. |
| setup/src/functions.ts | Stops reading/printing/returning VITE_REDIRECT_URL from .env. |
| products/frontend/src/routes/Share/components/Header/index.tsx | Removes auto-redirect-to-login on session error; shows login link when not authenticated. |
| products/frontend/src/routes/SessionCheck/index.tsx | Adds redirect query propagation on auth failure and safe redirect after session success. |
| products/frontend/src/routes/Profile/components/SocialLink/index.tsx | Uses VITE_CLIENT_URL for social link callback URL. |
| products/frontend/src/routes/Login/index.tsx | Builds OAuth callback URL from VITE_CLIENT_URL plus safe redirect query param. |
| products/frontend/src/lib/redirect.ts | Introduces safe redirect parsing and callback URL construction helpers. |
| products/frontend/.env.example | Removes VITE_REDIRECT_URL from example env file. |
| .env.example | Removes VITE_REDIRECT_URL from root example env file. |
| .github/workflows/preview-frontend.yaml | Removes VITE_REDIRECT_URL from preview build env. |
| .github/workflows/deploy-frontend.yaml | Removes VITE_REDIRECT_URL from deploy build env. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) : ( | ||
| <NavLink className={styles.navLink} to="/login"> | ||
| ログイン | ||
| </NavLink> | ||
| )} |
There was a problem hiding this comment.
The UI can briefly show the "ログイン" link even for authenticated users: isSuccess can become true before the async generateIdenteapot(...) finishes and sets identicon, so the ternary falls into the login branch until identicon is populated. Consider rendering the login link only when the session check is definitively unauthenticated (e.g., isError), and render nothing/placeholder while isPending or while isSuccess but identicon is still loading.
| ) : ( | |
| <NavLink className={styles.navLink} to="/login"> | |
| ログイン | |
| </NavLink> | |
| )} | |
| ) : sessionCheckMutation.isError ? ( | |
| <NavLink className={styles.navLink} to="/login"> | |
| ログイン | |
| </NavLink> | |
| ) : null} |
| const Login: FC = () => { | ||
| // callbackURLを構築 | ||
| // 1. 現在のURLを取得 | ||
| // status: https://pay-crew2.yukiosada.work/login?redirect=/some/safe/path |
There was a problem hiding this comment.
The inline example URL in this comment hard-codes a specific production domain (pay-crew2.yukiosada.work). This can become outdated/misleading for other environments; consider using a generic placeholder domain (e.g. https://example.com/...) or describing the shape of the URL without a concrete host.
| // status: https://pay-crew2.yukiosada.work/login?redirect=/some/safe/path | |
| // status: https://example.com/login?redirect=/some/safe/path |
No description provided.