fix: add Content-Type handling in attachment upload; update schema wi…#254
Conversation
…th description column migration Closes #236
📝 WalkthroughWalkthroughTwo targeted changes address file upload issues: the frontend API service now explicitly sets Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
frontend/src/services/api.jsx (1)
93-99: Remove global Content-Type header and rely on Axios auto-detection instead of the undefined workaround.The current
'Content-Type': undefinedworkaround on theuploadmethod works in Axios 1.15.0, but it's a special-case solution. Axios automatically detects and setsContent-Type: application/jsonfor plain object payloads andContent-Type: multipart/form-data(with correct boundary) for FormData payloads—no explicit header needed.Removing the global
'Content-Type': 'application/json'from the axios instance and letting Axios auto-detect headers is more durable: the upload method then works without special handling, and any future multipart endpoints work automatically.Refactor
const api = axios.create({ - baseURL: API_BASE_URL, - headers: { - 'Content-Type': 'application/json' - } + baseURL: API_BASE_URL });- upload: (recordId, formData) => api.post(`/attachments/record/${recordId}`, formData, { - headers: { 'Content-Type': undefined } - }), + upload: (recordId, formData) => api.post(`/attachments/record/${recordId}`, formData),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/services/api.jsx` around lines 93 - 99, The upload workaround sets 'Content-Type': undefined on attachmentService.upload; instead remove the header override here and also remove the global 'Content-Type': 'application/json' from the axios instance configuration so Axios can auto-detect headers for FormData. Specifically, delete the headers: { 'Content-Type': undefined } override in attachmentService.upload and update the axios instance creation (the api instance) to not set a global Content-Type so multipart/form-data requests are handled automatically by Axios.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/services/api.jsx`:
- Around line 93-99: The upload workaround sets 'Content-Type': undefined on
attachmentService.upload; instead remove the header override here and also
remove the global 'Content-Type': 'application/json' from the axios instance
configuration so Axios can auto-detect headers for FormData. Specifically,
delete the headers: { 'Content-Type': undefined } override in
attachmentService.upload and update the axios instance creation (the api
instance) to not set a global Content-Type so multipart/form-data requests are
handled automatically by Axios.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0e646da0-bb49-4c5b-9756-69c3a221c259
📒 Files selected for processing (2)
frontend/src/services/api.jsxsrc/main/resources/schema.sql
…th description column migration
Closes #236
Summary by CodeRabbit
Bug Fixes
Database Changes