# Supabase Storage file links broken: private bucket, getPublicUrl and expired signed URLs

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-storage-private-bucket-file-url-broken-signed-url.html
> Category: Database / Supabase RLS | Tools: Lovable, Bolt, Cursor, Replit, v0 | Published: 2026-11-24 | Updated: 2026-11-24

## The error

Images show as broken icons and opening the file link shows {"statusCode":"404","error":"Bucket not found"} even though the bucket exists / the browser console shows 400 (Bad Request) for /storage/v1/object/public/... / file links worked yesterday and now return InvalidJWT "exp" claim timestamp check failed / createSignedUrl returns Object not found / the image only loads for me, not for other users

## Why it happens

Supabase Storage buckets are private by default, and a private bucket has no public link. Supabase gives you only two ways to read a file from a private bucket: download it with the signed-in user's token (which your Storage policies check), or create a signed URL with createSignedUrl that works for a limited time. AI builders often create the bucket private (the default) but write getPublicUrl(), which only builds an address for a public bucket. Supabase's reference says this function does not check whether the bucket is public, so it never fails or warns; when a browser opens that /object/public/ address, Storage only looks among public buckets and answers Bucket not found. The second version of the problem is a signed URL saved into a table: createSignedUrl takes expiresIn in seconds, the link stops working when that time passes, and the saved link stays broken forever. A third version: createSignedUrl itself checks your Row Level Security policies on storage.objects, so without a SELECT policy that lets this user read the file it answers Object not found. The tempting quick fix, making the bucket public, means anyone with the link can read every file in it, which is fine for avatars and product photos but not for invoices, IDs or private uploads.

## How to fix it

1. Find out which case you have. Copy a broken file link and look at it. If it contains /storage/v1/object/public/<bucket>/, open Storage > Buckets in the Supabase dashboard (or run select id, public from storage.buckets; in the SQL Editor) and check whether that bucket is public. Public = false means case 1: a public link to a private bucket. If the link contains /object/sign/ and ?token=, it is a signed URL and has probably expired (case 2). Also check the bucket name matches exactly, including capitals.
2. Decide public or private on purpose. Ask: should anyone who gets the link be able to see this file? Avatars, product photos and blog images: usually yes, so a public bucket is fine. Supabase notes public buckets also cache better. Invoices, ID scans, contracts, private photos and anything per user: no, keep the bucket private. Public only opens reading; uploads, deletes and moves still need policies on storage.objects.
3. For a public bucket, keep getPublicUrl. Turn on Public bucket in the bucket settings, or run update storage.buckets set public = true where id = 'your-bucket'; Existing getPublicUrl links start working. Do not do this for a bucket that holds private files, because every file in it becomes readable by anyone with its address.
4. For a private bucket, replace getPublicUrl with createSignedUrl. Call supabase.storage.from('documents').createSignedUrl(path, 3600) when you are about to show the file and use data.signedUrl as the img src or download link. The second argument is seconds until expiry (3600 = one hour). For many files use createSignedUrls(paths, 3600) in one call. Pass { download: true } if the link should download instead of open.
5. Save the file path, never the signed link. In your table store only the object path (for example user-id/invoice-42.pdf). Create a fresh signed URL each time the page loads or the file is shown. If you already saved signed links, write a one-off script that strips them back to paths, and change the upload code so it stops saving signedUrl.
6. Add the Storage policy that lets the right user read the file. Signed URLs are only created for files the requesting user may read under the SELECT policies on storage.objects, otherwise you get Object not found. A common pattern is uploading to a folder named after the user id and a SELECT policy such as bucket_id = 'documents' and (storage.foldername(name))[1] = (select auth.jwt()->>'sub'). Never put the service role key in the browser to make the error go away; it bypasses all policies.
7. Pick a sensible expiry. Short links (minutes to an hour) are safer for private files. Supabase notes you cannot revoke a single signed URL: to cut one off early you must delete, move or rename the file, or rotate the project's URL signing key. Do not create week-long links for private documents just to avoid regenerating them.
8. Verify. Sign in as a normal user in a private window and check the image or file opens. Sign in as a second user and check they cannot get the first user's file. Open an old public link to a private file: it should still fail. Wait past the expiry of a short test link and confirm the page creates a new one instead of showing a broken image.

## Error codes this fixes

- `Bucket not found (on a /storage/v1/object/public/ link)` (Supabase Storage (HTTP 400, statusCode 404 in the body)): https://unbreakmyapp.vercel.app/errors.html#bucket-not-found-on-a-storage-v1-object-public-link
- `InvalidJWT: "exp" claim timestamp check failed (Storage signed URL)` (Supabase Storage): https://unbreakmyapp.vercel.app/errors.html#invalidjwt-exp-claim-timestamp-check-failed-storage-signed-u

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Images and files from Supabase Storage are broken in my app (Bucket not found, InvalidJWT exp claim timestamp check failed, or Object not found). Do not make a private bucket public, do not disable Row Level Security and do not use the service role key in the browser. 1) List every bucket the app uses, whether it is public or private, and what kind of files it holds. 2) For buckets that hold private or per-user files, replace every getPublicUrl call with createSignedUrl (or createSignedUrls for lists) with a short expiry, created when the file is shown. 3) Change the database so tables store only the object path, not a signed or public URL, and give me a one-off script to convert existing rows. 4) Show me the SELECT policies on storage.objects and add one that only lets each user read files in a folder named after their own user id. 5) Tell me how to test this with two different user accounts.
```

## FAQ

### Why does my Supabase file link say Bucket not found when the bucket exists?

Because the link is a public link (/storage/v1/object/public/...) and the bucket is private. Storage only looks among public buckets for that kind of link, so a private bucket is treated as not found. Make the bucket public if the files are meant to be public, or use createSignedUrl.

### Why do my Supabase signed URLs stop working?

A signed URL expires after the number of seconds you passed to createSignedUrl. After that Storage rejects it with an InvalidJWT error such as exp claim timestamp check failed. Store the file path in your table and create a fresh signed URL each time you show the file.

### Should I just make my Supabase Storage bucket public?

Only if anyone with the link may see every file in it, for example avatars or product photos. Public buckets skip access checks for reading. Keep invoices, IDs and private user uploads in a private bucket and use signed URLs.

### Why does createSignedUrl return Object not found?

Either the path is wrong or your Storage policies do not let this user read the file. Creating a signed URL checks the SELECT policies on storage.objects. Check the exact path, then add a SELECT policy for the right users.

### Can I cancel a signed URL I already shared?

Not one by one. Supabase says you cannot revoke individual signed URLs; delete, move or rename the file to stop that link, or rotate your project's URL signing key to stop all of them. Use short expiry times for private files.

## Sources (official documentation)

- [Supabase: Storage buckets (public vs private, private by default)](https://supabase.com/docs/guides/storage/buckets/fundamentals)
- [Supabase: Serving assets from Storage (public URLs, signed URLs, revoking)](https://supabase.com/docs/guides/storage/serving/downloads)
- [Supabase JS reference: getPublicUrl (does not verify the bucket is public)](https://supabase.com/docs/reference/javascript/storage-from-getpublicurl)
- [Supabase JS reference: createSignedUrl (expiresIn in seconds)](https://supabase.com/docs/reference/javascript/storage-from-createsignedurl)
- [Supabase JS reference: createSignedUrls](https://supabase.com/docs/reference/javascript/storage-from-createsignedurls)
- [Supabase: Storage access control (policies on storage.objects, signed URLs)](https://supabase.com/docs/guides/storage/security/access-control)
- [Supabase: Storage error codes](https://supabase.com/docs/guides/storage/debugging/error-codes)
- [Supabase: Creating buckets](https://supabase.com/docs/guides/storage/buckets/creating-buckets)
- [Supabase: Storage CDN (public vs private caching)](https://supabase.com/docs/guides/storage/cdn/fundamentals)
- [Supabase Storage source: public object route only serves public buckets](https://github.com/supabase/storage/blob/master/src/http/routes/object/getPublicObject.ts)

## Related fixes

- [Supabase Storage upload fails: new row violates row-level security policy (403)](https://unbreakmyapp.vercel.app/fixes/supabase-storage-upload-403.html)
- [Supabase query returns an empty array (no error)](https://unbreakmyapp.vercel.app/fixes/supabase-rls-empty-results.html)
- [Supabase table has RLS disabled (public Data API access)](https://unbreakmyapp.vercel.app/fixes/supabase-rls-disabled-table-public.html)
- [Is my Lovable app leaking data without login? A Supabase RLS audit checklist after the Crissy Field study](https://unbreakmyapp.vercel.app/fixes/lovable-app-leaking-data-without-login-audit-checklist.html)
- [OpenAI / Stripe secret key leaked in the browser](https://unbreakmyapp.vercel.app/fixes/api-key-leaked-in-frontend.html)
- [Changing the id in the URL shows other users' data (IDOR)](https://unbreakmyapp.vercel.app/fixes/change-id-in-url-see-other-users-data-idor.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
