Skip to content

fix: allow Vercel preview deployments via wildcard CORS#4

Open
sktbrd wants to merge 46 commits into
bgrana75:mainfrom
SkateHive:fix/cors-vercel-previews
Open

fix: allow Vercel preview deployments via wildcard CORS#4
sktbrd wants to merge 46 commits into
bgrana75:mainfrom
SkateHive:fix/cors-vercel-previews

Conversation

@sktbrd

@sktbrd sktbrd commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds wildcard pattern matching to isOriginAllowed() — entries like https://*.vercel.app now match any preview URL (e.g. skatehive3-0-gdgt8ea4v-sktbrds-projects.vercel.app)
  • Includes https://*.vercel.app in the default ALLOWED_ORIGINS so Vercel previews work without any .env changes
  • ALLOWED_ORIGINS env var supports * wildcards for custom patterns

Test plan

  • Open a Vercel preview URL and confirm /transcode and /progress/:requestId requests succeed without CORS errors
  • Confirm https://skatehive.app still works (exact match path)
  • Confirm a random unknown origin is still blocked

🤖 Generated with Claude Code

sktbrd and others added 30 commits August 19, 2025 13:49
…tegration

- Added detailed request/response logging for dashboard monitoring
- Enhanced CORS headers for web application compatibility
- Added client IP tracking and request ID generation
- Improved error handling and cleanup logging
- Added progress tracking for FFmpeg and IPFS upload operations
- Fixed Tailscale funnel integration for external access
…vice

- Added 'cors' dependency to package.json and package-lock.json.
- Updated server.js to implement a more robust CORS setup allowing specific origins and methods.
- Improved logging for incoming requests, including detailed information for transcoding operations.
- Enhanced error handling and cleanup processes during video transcoding.
- Created a backup of the original server.js for reference.
- Added a sample video file for testing purposes.
…etup

- Clarify internal port 8080 vs external port 8081
- Add production deployment section with Mac Mini M4 configuration
- Document Tailscale Funnel routing
- Add health check endpoint examples
Updates the log to include new video transcode events for multiple users and devices, while removing earlier entries to maintain relevance and reduce log size. Helps keep logs current for monitoring and troubleshooting.
sktbrd and others added 16 commits December 12, 2025 16:06
Includes an additional node property in the logged output
to enhance traceability and support debugging across
distributed environments.
…gress

- Add /progress/:requestId SSE endpoint for real-time progress streaming
- Add activeJobs Map to track progress and SSE clients per request
- Add broadcastProgress() to send updates to all connected clients
- Add getVideoDuration() using ffprobe for accurate progress calculation
- Parse FFmpeg stderr for time progress during transcoding
- Use client's correlationId for SSE (enables pre-subscription)
- Preserve existing SSE clients when initializing job tracking
- Progress stages: receiving (5%), transcoding (0-80%), uploading (80-100%), complete
- Use ipfs.skatehive.app gateway (branded custom gateway)
- Add PINATA_GROUP_VIDEOS support for organized uploads
- Standardize metadata to match webapp schema
- Add missing fields: fileType, uploadDate, transcoded, videoDuration, originalFileName
- Add conditional fields: viewport, connectionType
- Preserve backward compatibility with sourceApp/appVersion
- Removed less critical fields to comply with Pinata 10 keyvalue limit
- Kept essential fields: creator, source, uploadDate, transcoded, originalFileName, videoDuration, requestId, sourceApp, platform, thumbnailUrl
- Fixed empty string issue (only include non-empty optional fields)
- Added detailed Pinata error logging for debugging
…lity

- Add checkWebOptimized() — ffprobe checks if H.264/AAC/≤1080p before transcoding
- Optimized videos skip transcoding, upload directly to IPFS (2x faster)
- Adaptive CRF: 20 (short clips) / 22 (normal) / 24 (long/large)
- Cap resolution at 1080p, bitrate at 5Mbps
- Default preset changed to medium (better quality)
- Remove obsolete docker-compose version key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Generate JPEG thumbnail with FFmpeg (frame at 10% duration, max 640px)
- Upload thumbnail to Pinata and store URL in video metadata
- Falls back gracefully if thumbnail generation fails
- Client-provided thumbnails still take priority

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add -pix_fmt yuv420p to the ffmpeg args so all transcoded output is
guaranteed 8-bit 4:2:0 — required for hardware decode on iOS/Android.

Also extend checkWebOptimized to reject videos whose pix_fmt is not
yuv420p (e.g. 10-bit h264), so they go through re-encoding instead
of being passed through as-is.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pinata intermittently returns 400 errors during video upload, causing
the entire transcode to fail with no retry. This adds a 3-attempt retry
loop with 2s/4s backoff, and logs the actual Pinata response body so
we can diagnose the root cause when it fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds wildcard pattern support to origin matching so that
https://*.vercel.app previews are accepted without hardcoding
each deployment URL. ALLOWED_ORIGINS env var also supports
wildcards for custom patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant