-
Notifications
You must be signed in to change notification settings - Fork 16
fix: update headers #362
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
fix: update headers #362
Conversation
WalkthroughThree functions in Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Caller (UI / Service)
participant API as storageAPI.getHeaders
participant Axios as axios
Note over UI,API: New header flow — API key from env, optional csrfToken param
UI->>API: getHeaders(optional csrfToken)
API-->>UI: headers { Authorization: env-key, X-CSRF-Token? }
UI->>Axios: axios request (headers returned, withCredentials as needed)
Axios-->>UI: response (may include csrfToken for fetchCsrfToken flow)
rect rgb(230,245,255)
Note right of API: getHeaders no longer accepts documentStorage\nthrows if env var missing
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/common/API/storageAPI.tsx(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Redirect rules - tradetrust-creator
- GitHub Check: Header rules - tradetrust-creator
- GitHub Check: Pages changed - tradetrust-creator
- GitHub Check: Lint & Test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/common/API/storageAPI.tsx (1)
36-38: Consider validating the API key at application startup.While throwing an error when the API key is missing is good defensive programming, it only catches the issue at runtime when
getHeadersis called. Consider validatingREACT_APP_API_KEY_DOCUMENT_STORAGEat application initialization for earlier error detection and better developer experience.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/common/API/storageAPI.tsx(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Redirect rules - tradetrust-creator
- GitHub Check: Header rules - tradetrust-creator
- GitHub Check: Pages changed - tradetrust-creator
- GitHub Check: Lint & Test
🔇 Additional comments (4)
src/common/API/storageAPI.tsx (4)
15-15: LGTM! Correctly callsgetHeaders()without CSRF token.The call to
getHeaders()without parameters is correct here since this function is fetching the CSRF token itself. The previous issue about missingdocumentStorageparameter has been resolved by the refactor.
55-55: LGTM! Correctly omits CSRF token for GET request.The call to
getHeaders()without a CSRF token is appropriate for this GET request. CSRF protection is typically only required for state-changing operations. The previous issue about missingdocumentStorageparameter has been resolved by the refactor.
72-72: LGTM! Correctly includes CSRF token for POST request.The call to
getHeaders(csrfToken)is correct for this POST request. The CSRF token is properly included to protect against CSRF attacks on state-changing operations. The previous issue about incorrect parameter type has been resolved.
29-47: Verification complete—no issues found.All callers of
getHeaderswithin the codebase have been properly updated to match the new signature. The function is only used internally in storageAPI.tsx and is not exported, so the architectural change from per-storage API keys to a centralized environment variable has no impact on other files. Error handling for a missing API key is in place.
Summary by CodeRabbit