feat: Consolidate Apollo Client, update CSRF logic, and related refactors (#4006)#4007
feat: Consolidate Apollo Client, update CSRF logic, and related refactors (#4006)#4007DhineshPonnarasan wants to merge 1 commit intoOWASP:mainfrom
Conversation
|
Caution Review failedThe pull request is closed. Summary by CodeRabbit
WalkthroughThis PR refactors Apollo Client initialization from a server-specific module to a unified lib module with environment-aware setup, adds runtime validation guards in the auth route, updates CSRF token handling, introduces error utilities, and relocates imports across multiple layout files. Additionally, a Docker automation script is added. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
PR validation failed: No linked issue and no valid closing issue reference in PR description |
|
There was a problem hiding this comment.
1 issue found across 19 files
Confidence score: 4/5
- This PR looks safe to merge overall; the only noted issue is a small Windows batch usability concern rather than core logic.
run_app.batusescd %~dp0, which can fail on drive changes or paths with spaces, potentially breaking script execution in those setups.- Pay close attention to
run_app.bat- ensure directory change handles drive letters and spaces.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="run_app.bat">
<violation number="1" location="run_app.bat:2">
P2: Windows batch `cd %~dp0` should use `cd /d "%~dp0"` to handle drive changes and paths with spaces</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -0,0 +1,3 @@ | |||
| @echo off | |||
| cd %~dp0 | |||
There was a problem hiding this comment.
P2: Windows batch cd %~dp0 should use cd /d "%~dp0" to handle drive changes and paths with spaces
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At run_app.bat, line 2:
<comment>Windows batch `cd %~dp0` should use `cd /d "%~dp0"` to handle drive changes and paths with spaces</comment>
<file context>
@@ -0,0 +1,3 @@
+@echo off
+cd %~dp0
+docker compose -f docker-compose\local\compose.yaml --project-name nest-local up -d --build
</file context>



Consolidate Apollo Client & Refactor CSRF Logic
Overview
This PR consolidates all Apollo Client logic into a single, shared implementation and refactors CSRF handling for improved reliability and SSR/client boundary safety. It also cleans up related files, updates imports, and removes redundant code.
Key Changes
Apollo Client Consolidation
Merged multiple apolloClient.ts implementations into a single shared file at apolloClient.ts.
Removed old and redundant Apollo Client files from server and helpers.
Updated all imports across the codebase to use the new shared Apollo Client.
CSRF Logic Refactor
Refactored fetchCsrfToken.ts for robust, server-only CSRF token fetching.
Improved error handling and boundary safety for SSR/client scenarios.
Algolia Search & Utility Updates
Cleaned up fetchAlgoliaData.ts to remove shell output and ensure valid TypeScript.
Added debug logging for easier troubleshooting.
Updated utility and error handling files for consistency.
General Cleanup
Removed unused or duplicate files.
Updated and cleaned up related files and imports.
Added/updated appError.ts for unified error handling.
Added/updated run_app.bat for easier local development.
Motivation
Reduce code duplication and maintenance overhead.
Ensure Apollo Client and CSRF logic are robust, secure, and SSR-safe.
Fix build/runtime errors and improve developer experience.
Prepare the codebase for future enhancements and easier onboarding.
Testing
All changes build and run locally without errors.
Manual testing of authentication, search, and Apollo queries/mutations.
Verified SSR/client boundaries and error handling.
Checklist
Please review and let me know if any further changes are needed!