fix(pdf): PDF previews by adding the missing preview endpoint and allowing same-origin blob URLs in iframe CSP#4225
Conversation
…owing same-origin blob URLs in iframe CSP
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The shared route enforces consistent auth + workspace membership checks, JSON/ Updates CSP Reviewed by Cursor Bugbot for commit ef2b8b2. Configure here. |
|
bugbot run |
|
@greptile |
Greptile SummaryThis PR adds the missing PDF preview API endpoint ( The refactoring is clean: auth, membership verification, JSON parsing, code validation, size guard, and sandbox dispatch are all handled once in Confidence Score: 5/5Safe to merge — clean refactor with comprehensive test coverage and no functional regressions. All changed files follow project conventions (toError, createLogger, absolute imports, vi.hoisted mocking). The shared factory eliminates duplication across three routes. Test suites cover every response branch including auth failures previously flagged in review. The CSP change (blob: in frame-src) is the minimum required to unblock iframe PDF rendering and is acceptable since blob URLs are inherently same-origin. No P0 or P1 issues found. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[POST to document preview endpoint] --> B[createDocumentPreviewRoute factory]
B --> C{Authenticated?}
C -- No --> D[401 Unauthorized]
C -- Yes --> E{Workspace member?}
E -- No --> F[403 Insufficient permissions]
E -- Yes --> G{Valid JSON body?}
G -- No --> H[400 Invalid JSON]
G -- Yes --> I{code present and non-empty?}
I -- No --> J[400 code is required]
I -- Yes --> K{code within 1 MB?}
K -- No --> L[413 code exceeds maximum size]
K -- Yes --> M[runSandboxTask with ownerKey and abort signal]
M -- Success --> N[200 binary document response]
M -- Error --> O[500 with error message]
Reviews (2): Last reviewed commit: "follow nextjs route gen strat" | Re-trigger Greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6f693c1. Configure here.
|
bugbot run |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ef2b8b2. Configure here.
Summary
PDF previews by adding the missing preview endpoint and allowing same-origin blob URLs in iframe CSP
Type of Change
Testing
Tested manually
Checklist