Shared links to a fashion image site were opening onto an error message instead of the image. The detail view looked broken, so the natural suspects were the image itself, the storage behind it, or the share URL. None of those were the problem. The image had loaded and rendered. Something that ran after it took the page away.

A side effect with the power to undo the main effect

Before the fix, the site answered plain HTTP with a normal 200, exactly as it answered HTTPS. A link that started with http:// stayed on an insecure page. On such a page, crypto.randomUUID may not be available, because browsers only promise it in a secure context. The site called it directly in two places: to give each visit event an ID, and to give each download an ID.

The detail view rendered the content first and then called track('image_open'). That call needed a UUID. When it threw, the surrounding catch did what catch blocks in display code often do: it replaced the view with an error message. A failed analytics event, which nobody would see, was allowed to erase an image that had already been drawn successfully.

Two fixes, one for each layer

The first fix closes the door: every HTTP request is now redirected with a 308 to the same path and query on HTTPS, before any other handling. That covers the home page, image pages, static files and the API. Even a screen that was opened over HTTP earlier now hands out an HTTPS link when someone presses Share.

The second fix makes the client survive the case anyway. Event IDs use randomUUID when it exists and otherwise build a version-4 UUID from crypto.getRandomValues. If no cryptographic random source exists at all, the analytics event is skipped and a download shows a note asking for a secure connection.

The test suite passed 31 of 31, including path and query preservation and the UUID fallback. In Chromium, with randomUUID deliberately removed, a shared link showed the 1024px image with no error text. In production, HTTP requests for the home page, an image, an old shared URL, a script and the API each returned 308 to HTTPS, and a 390px mobile view followed the redirect and loaded the image. That reproduction was simulated; I did not capture the original failing browser. Opening a link inside a messaging app on a real phone, and completing a real account sign-in, were outside this check.

Telemetry should be able to fail without anyone noticing, and the page should be the last thing allowed to break because of it.