Public brand image fetch: the site's configured origin only, no redirect followed, a time and a byte limit

/api/ipal/admin-og resolved a relative logo address against the request's own host and fetched it with
Node's defaults (redirects followed, no timeout, no size cap); /api/ipal/admin-icon resolved the same way.
Both now resolve against serverURL / NEXT_PUBLIC_SERVER_URL (never the request) and fetch through
fetchPublicImage, which asks one address with redirect: 'manual' (a 3xx is no image), within
PUBLIC_IMAGE_TIMEOUT_MS, reading at most 512 KB. The renderer still draws PNG, JPEG, GIF (by their bytes)
and SVG (by its type, as before). Tests against local servers: hostile Host / X-Forwarded-Host, a 302 to an
internal host, an endless body, a hanging server, the normal logo. Docs say 1.17.1 instead of 1.18.0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:03:52 +01:00
co-authored by Claude Fable 5.2
parent 562bf5388d
commit aef1efac73
13 changed files with 244 additions and 29 deletions
+6
View File
@@ -100,6 +100,12 @@ image. The plugin now fills the panel's `<head>` from Site settings, **with or w
(`syncAdminMeta`). Keys you set in `admin.meta` are never touched.
- **The image** is drawn on the server with `next/og` (no external service, cached 1 h). The logo is
read from the upload itself: PNG, JPG, GIF or SVG; a WebP/AVIF logo falls back to the site name.
- **How the server fetches the logo and icon (1.17.1):** a site-relative upload address is resolved against the
site's **configured** origin — `serverURL`, else `NEXT_PUBLIC_SERVER_URL` — never against the request's `Host`
or `X-Forwarded-Host` (the endpoints are public; a request names its own host). No configured origin: a
relative address is not fetched (the site name / the redirect to the media file is used). One address is
asked, **a redirect is never followed**, the whole exchange has 5 s, and reading stops at 512 KB whatever
the server says about the length. Set `serverURL` (every IAPL site does) for the logo to appear.
The image endpoints are public (link previews fetch without a session) and show only the logo and
name the site shows anyway. Fields: `whiteLabel.settingsSlug` / `nameField` / `logoField` / `iconField`.
- **No import map step** — no new admin components (endpoints only).