sim icon indicating copy to clipboard operation
sim copied to clipboard

Fix drag-and-drop functionality with Cloudflare Tunnel

Open devdattatalele opened this issue 4 months ago • 1 comments

Summary

Resolves drag-and-drop functionality failures when the application is served via Cloudflare Tunnel by implementing a robust MIME type fallback system.

Problem Statement

Users reported that dragging blocks (Agent, Knowledge, etc.) onto the workflow canvas failed when accessing the application through Cloudflare Tunnel. The issue occurred because:

  • Cloudflare Tunnel normalizes custom MIME types to standard ones
  • The existing drag-drop validation rejected normalized MIME types
  • No network requests were triggered, causing silent failures

Solution Implementation

Comprehensive MIME Type Fallback System:

New Utilities (lib/drag-drop-utils.ts)

  • Multi-MIME type validation with priority fallbacks
  • Robust data extraction handling normalized MIME types
  • Production-safe debugging with environment controls
  • Type-safe implementation with proper error handling

Enhanced Components

  • workflow.tsx: Updated drop handlers with fallback MIME type support
  • toolbar-block.tsx: Multiple MIME type data setting for compatibility

Technical Details

MIME Type Priority System:

  1. application/sim-block (custom, ideal case)
  2. application/json (Cloudflare normalized)
  3. text/plain (maximum compatibility)
  4. text/json (alternative JSON format)

Key Features:

  • Performance optimized with early termination on success
  • Backward compatible with existing functionality
  • Comprehensive validation and error handling
  • Production logging controls (NODE_ENV checks)

Validation

  • Handles Cloudflare Tunnel MIME type normalization
  • Maintains compatibility with direct access scenarios
  • No breaking changes to existing drag-drop behavior
  • Proper error logging for debugging future issues

Fixes #1268

devdattatalele avatar Sep 07 '25 19:09 devdattatalele

@devdattatalele is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 07 '25 19:09 vercel[bot]