fix(debrid): handle HEAD requests on playback route#1010
Conversation
…mpatibility Replace the blanket 405 for all HEAD requests with a lightweight HEAD handler on the playback route that validates the encrypted token and file info without hitting the debrid provider, then returns 200 with Content-Type: video/mp4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughReplaces middleware that rejected HEAD requests with a dedicated HEAD handler for the playback route. The handler parses/looks up ChangesHEAD Endpoint Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/server/src/routes/api/debrid.ts`:
- Around line 36-84: The HEAD handler for
'/playback/:encryptedStoreAuth/:fileInfo/:metadataId/:filename' currently never
validates the metadataId so it can return 200 when the GET route would reject
with "Metadata not found"; update the handler to perform the same metadata
existence check used by the GET metadata gate (i.e., validate
req.params.metadataId using the same lookup/function the GET route uses) and if
the metadata is missing call next(new APIError(constants.ErrorCode.BAD_REQUEST,
undefined, 'Metadata not found')) and return; keep the existing FileInfoSchema
and ServiceAuthSchema parsing and decryption logic but add the metadataId lookup
(using the same store/get function or helper used by the GET route) before
sending the 200 response so HEAD and GET stay aligned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e1c505ad-0f7d-495e-b485-7ec4265d6230
📒 Files selected for processing (1)
packages/server/src/routes/api/debrid.ts
HEAD handler now captures fileInfo result and checks metadataStore when serviceItemId is absent, matching the GET route's validation logic so HEAD no longer returns 200 for requests the GET route would reject. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the blanket 405 for all HEAD requests with a lightweight HEAD handler on the playback route that validates the encrypted token and file info without hitting the debrid provider, then returns 200 with Content-Type: video/mp4.
Summary by CodeRabbit