Signed URLs Expiring Too Fast in Windsurf App
Images, documents, and file download links in your Windsurf-generated app break after a short time. Users see broken images, get access denied errors when clicking download links, or see files that loaded fine moments ago now showing 403 Forbidden errors.
This happens because your app uses signed URLs to serve files from private cloud storage (Supabase Storage, S3, or GCS), and the URLs expire too quickly. Cascade may have set a very short expiration time, or the URLs are being generated once and cached while the expiration passes.
The issue is especially frustrating for users because everything appears to work initially, then breaks silently. Pages that worked fine a few minutes ago suddenly show broken images everywhere.
Error Messages You Might See
Common Causes
- Default short expiration — Cascade used the default signed URL expiration (often 60 seconds) without increasing it for the use case
- URLs cached but not refreshed — Signed URLs are generated once at page load and stored in state, but not regenerated when they expire
- Server-side rendering with stale URLs — URLs generated during SSR are already partially expired by the time the client receives them
- Email or notification links — Signed URLs sent in emails expire before the recipient opens the message
- CDN caching conflicts — A CDN caches the page with signed URLs, but the URLs expire before the CDN cache does
How to Fix It
- Increase signed URL expiration — Set expiration to match your use case: 1 hour for page views, 24 hours for download links, 7 days for email links
- Implement URL refresh logic — Create a client-side mechanism that regenerates signed URLs before they expire, or on 403 errors
- Use public buckets for non-sensitive files — If the files aren't private (like product images), make the bucket public and skip signed URLs entirely
- Add a redirect endpoint — For email links, create a permanent URL (/files/:id/download) that generates a fresh signed URL and redirects
- Set CDN cache to match URL expiration — Ensure CDN cache-control headers expire before the signed URLs they contain
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How long should I set signed URL expiration?
It depends on the use case. For images displayed on pages: 1-4 hours. For download links: 24 hours. For links in emails: 7 days. For public content that doesn't need access control, skip signed URLs and use public buckets.
Can signed URLs be extended after they are created?
No. Once a signed URL is generated, its expiration is fixed. You must generate a new signed URL. Design your app to either refresh URLs before expiry or use a redirect endpoint that generates fresh URLs on demand.