Category: Supabase and databases

Supabase: signed file URL stops working — differentiation and repair

Read this guide in Polish

The "signed URL ceases to work" report covers many unrelated causes: the presigned links expire, the object has been removed, the RLS/bucket law has changed, or the proxy/CDN caches the answer 403 Instead of updating the state. In practice, the client sees sudden 403 or 404 on the existing links. This requires sequential diagnostics — checking the expiry parameters, the integrity of the Storage object, the role of the key used to generate the link, the public/private configuration, the CDN/Cache-Control settings, and comparison of reply headers. The following text focuses on specific tests and corrective steps repetitive in real Supabase environments without assuming access to operating masters.

How to Recognize Cause

Check first if the answer is 403 (no permission) or 404 (no object). 404 means to delete or move a file; 403 — issue with authorization, token expiration or bucket policy. Use curl -I or web browser to read status and headers.

If status is 403, compare the way you generate signed URL: have you used the createSignedUrl method from the client on the server side or the unauthorized service role in the client? Check the TTL link (expiresIn) and the server system time (clock skin). CDN Reverse proxies can cache old 403 responses — check Cache-Control and X-Cache headers.

Step by step solution

1. Locate the object in the Supabase Storage panel: confirm file presence, path and metadata. If a file exists, save the exact path and size; if not, play it from backup or confirm who and when deleted.

2 . Generate a new signed URL on the server (not in the browser) using service role or server key in the short term and set TTL to a short value (e.g. 60s). Compare generated URLs and expires parameters with those that do not work.

3 . Follow curl -v "<signed url>" and note the answer: status code, body, Cache-Control headers, Age, X-Cache and Server-Timing. No body + 403 indicates authorization policy; 404 indicates no object. Register exact error messages.

4 . Check the roles and rules of the bucket: if the bucket is private, make sure you use the signed URL generated by the server. If new RLS/Policies policies are set against storage.objects, temporarily switch to a simple test policy and try again.

5 . Check the server/application clock (NTP): if the signature uses unix time, >60s can invalidate the URL. On the link generating machine, check date -u and compare with time.nist.gov; if different, configure NTP.

6 . Check CDN/Edge configuration: if Supabase or external CDN caches 403, clear cache for a given URL or header, and re-execute request with ?cachebust=timestamp parameter. Confirm if the source content has changed.

7 . View the Supabase logs (if available) and application server logs: find bugs related to the generation of URLs, exceptions when calling API storage.createSignedUrl, or references to rejection of token. Save the exact messages for analysis.

How to see if the problem is gone

Test 1 — instant access: after generating the new signed URL run curl -I and curl --max-time 10 and confirm code 200 and correct Content-Type and size. If 200 — the problem was in expiration or cache.

Test 2 — Expiration test: Generate the URL from TTL 10s, access immediately (expected 200), wait 15s and call again — should return 403 or 404. This test confirms that the TTL mechanism is working properly.

Test 3 — comparison without CDN: make a direct request to the Supabase with the cleared browser cache and the cachebust parameter, and omit any CDN (if possible). No difference indicates a problem on the Storage/ACL side.

What to do

Do not use service role in frontend application: key leak allows you to generate any signed URL and modify data. The server key always generates links on the backend side.

Do not extend the TTL signed URL above necessary without considering the risk: a long period increases the area of the attack when the link leaks; instead, apply a short TTL and refresh mechanism.

Do not assign reasons based on the title of the report: first make the code status + headers + file presence. Assuming that a CDN without a test can lead to an unnecessary change of configuration.