Skip to content

Conversation

@harshit078
Copy link
Contributor

Description

  • This PR address issue Images are not included in PDF exports #15998
  • The issue was that images are stored as signed urls and the backend signed these with JWT
  • BlockNote resolveFileUrl uses a public CORS proxy that couldn’t access authenticated/signed URLs

Visual Appearance

Screen.Recording.2025-11-26.at.1.56.03.AM.mov

Copilot AI review requested due to automatic review settings November 25, 2025 20:39
@harshit078 harshit078 changed the title fix: updated pdf exporter to handle cors response fix: images are not included in PDF exports Nov 25, 2025
Copilot finished reviewing on behalf of harshit078 November 25, 2025 20:43
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

Fixed PDF export to include images by providing custom resolveFileUrl implementation that fetches signed URLs directly from the browser instead of relying on BlockNote's default CORS proxy.

  • Added custom resolver that uses browser's fetch with CORS mode to access JWT-signed file URLs
  • Bypassed BlockNote's public CORS proxy which couldn't handle authenticated URLs
  • Used credentials: 'omit' since authentication token is embedded in URL path, not cookies

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly addresses the issue by providing a custom file resolver that works with the existing JWT-signed URL architecture. The solution is minimal, well-targeted, and uses appropriate fetch options
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts 5/5 Added custom resolveFileUrl to fetch signed URLs directly from browser, bypassing CORS proxy that couldn't access authenticated URLs

Sequence Diagram

sequenceDiagram
    participant User
    participant PDFExporter
    participant CustomResolver as resolveFileUrl
    participant Browser
    participant FileController
    participant FilePathGuard
    participant FileStorage

    User->>PDFExporter: Export note to PDF
    PDFExporter->>CustomResolver: Request image (signed URL)
    Note over CustomResolver: URL includes JWT token in path<br/>(e.g., /files/folder/TOKEN/image.jpg)
    CustomResolver->>Browser: fetch(url, {mode: 'cors', credentials: 'omit'})
    Browser->>FileController: GET /files/.../TOKEN/...
    FileController->>FilePathGuard: Verify JWT token
    FilePathGuard->>FilePathGuard: Extract token from URL path
    FilePathGuard->>FilePathGuard: Verify JWT signature & workspace
    FilePathGuard-->>FileController: Authorized (workspaceId added to request)
    FileController->>FileStorage: Fetch file stream
    FileStorage-->>FileController: File stream
    FileController-->>Browser: Image data (with CORS headers)
    Browser-->>CustomResolver: Blob
    CustomResolver-->>PDFExporter: Image blob
    PDFExporter->>User: Generated PDF with images
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where PDF export failed to include images stored as signed URLs. The problem was that BlockNote's default resolveFileUrl implementation uses a public CORS proxy that cannot access authenticated/signed URLs. The solution overrides this function to fetch resources directly from the client.

Key Changes

  • Added custom resolveFileUrl function to PDFExporter configuration
  • Implemented direct fetch with CORS mode and omitted credentials for signed URL access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:22974

This environment will automatically shut down when the PR is closed or after 5 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants