-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(cdn): add cdn for large video assets with fallback to static assets #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| @@ -1,5 +1,5 @@ | |||
| <p align="center"> | |||
| <img src="apps/sim/public/static/sim.png" alt="Sim Studio Logo" width="500"/> | |||
| <img src="https://nwkhgj772h6t23m2.public.blob.vercel-storage.com/static/sim.png" alt="Sim Studio Logo" width="500"/> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meant to be public, just incl our assets and generic images/videos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR implements a comprehensive CDN solution for large static assets to improve performance and reduce repository size. The changes introduce a new getAssetUrl utility function that provides intelligent asset delivery with fallback capabilities - assets are served from Vercel Blob Storage CDN when the NEXT_PUBLIC_BLOB_BASE_URL environment variable is configured, otherwise falling back to local static assets.
The implementation spans multiple areas of the codebase:
-
Environment Configuration: Added
NEXT_PUBLIC_BLOB_BASE_URLto the environment variables inapps/sim/lib/env.tswith proper validation and runtime environment mapping -
Security Configuration: Updated Content Security Policy (CSP) in
apps/sim/lib/security/csp.tsto allow image loading fromhttps://*.public.blob.vercel-storage.com -
Utility Functions: Created
getAssetUrlfunctions in bothapps/sim/lib/utils.tsandapps/docs/lib/utils.tsthat handle CDN URL construction with fallback logic -
Email Templates: Updated all email components (OTP verification, workspace invitation, reset password, invitation) to use the new CDN system for logos and images
-
Landing Page Components: Modified testimonials and blog sections to serve social media images and avatars through the CDN
-
Application Layout: Updated the main app layout's social media metadata images to use CDN URLs
-
Documentation: Updated README.md to directly reference CDN URLs for the logo and demo.gif
The solution achieves significant repository size reduction - from ~44.5MB to 4.5MB for the main app and ~304MB to 4MB for docs, totaling ~340MB savings. The architecture maintains backward compatibility through fallback mechanisms, ensuring the application continues to work in environments where CDN isn't configured.
Confidence score: 3/5
• This PR introduces significant infrastructure changes that could impact asset loading across the entire application
• The score reflects concerns about incomplete implementation in some areas and potential runtime errors if environment variables aren't properly configured
• Files requiring more attention: apps/sim/components/emails/workspace-invitation.tsx and all email templates for potential runtime issues if CDN configuration fails
13 files reviewed, 1 comment
…tic assets (simstudioai#809) * added CDN for large assets with fallback to static assets * remove video assets from docs --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
Description
add cdn for large video assets with fallback to static assets, serves assets much faster in email templates and docs and is cheaper as well
Type of change
How Has This Been Tested?
Tested manually to ensure we can read assets from public blob.
Checklist:
bun run test)Security Considerations:
Additional Information: