sim
sim copied to clipboard
Fix drag-and-drop functionality with Cloudflare Tunnel
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:
-
application/sim-block(custom, ideal case) -
application/json(Cloudflare normalized) -
text/plain(maximum compatibility) -
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 is attempting to deploy a commit to the Sim Team on Vercel.
A member of the Team first needs to authorize it.