Images : retour au chargement habituel (affiches cassées sur iPhone)
deploy / deploy (push) Successful in 44s

Les images TMDB / AniList étaient demandées en mode CORS (crossOrigin) depuis 425bff8. Sur iPhone, les
affiches déjà en mémoire, reçues sans en-tête CORS, étaient alors refusées : bannière, affiches et vignettes
vides. Retour à l'ancien fonctionnement (caches posters / backdrops, réponses opaques acceptées) ;
les caches posters-v2 / backdrops-v2 de l'essai sont supprimés au lancement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-11-29 21:26:54 +00:00
1 parent 26a2b10b1a
commit 82bdaac3fe
14 files changed
+24 -44

No files matched your search

+3 -3
View File
@@ -3,7 +3,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
import { dateFormat, t } from '../i18n'
import { cachedSeasonEpisodes, episodeWindow, getTmdbSeasonEpisodes, preloadImages, type EpisodeInfo } from '../lib/catalogApi'
import { episodeCap, episodesBeforeSeason, seasonPosition } from '../lib/franchise'
import { tmdbSized, imgCors } from '../lib/tmdbImage'
import { tmdbSized } from '../lib/tmdbImage'
import { cx, todayISO } from '../lib/utils'
import { useMedia } from '../store'
import type { MediaInput } from '../types'
@@ -144,11 +144,11 @@ export default function EpisodeList({ form, aired, onChange, fallbackImage }: Pr
>
<span className="relative aspect-video w-28 shrink-0 overflow-hidden rounded-lg border border-line bg-surface-2">
{e.still ? (
<img src={e.still} crossOrigin={imgCors(e.still)} alt="" loading={visible.has(e.number) ? 'eager' : 'lazy'} decoding="async" className="size-full object-cover" />
<img src={e.still} alt="" loading={visible.has(e.number) ? 'eager' : 'lazy'} decoding="async" className="size-full object-cover" />
) : fallbackImage ? (
// Pas d'image pour cet épisode : celle de la série, assombrie, avec le numéro par-dessus
<>
<img src={tmdbSized(fallbackImage, 'w300')} crossOrigin={imgCors(tmdbSized(fallbackImage, 'w300'))} alt="" loading="lazy" decoding="async" className="size-full object-cover" />
<img src={tmdbSized(fallbackImage, 'w300')} alt="" loading="lazy" decoding="async" className="size-full object-cover" />
<span className="absolute inset-0 grid place-items-center bg-black/50 text-base font-bold text-white">{e.number}</span>
</>
) : (
+2 -3
View File
@@ -7,7 +7,7 @@ import { canWatchMore, nextAirDate } from '../lib/airing'
import { episodeCap, seasonPosition } from '../lib/franchise'
import { progressView } from '../lib/rewatch'
import { genreLabel } from '../lib/genres'
import { backdropSrcSet, tmdbSized, imgCors } from '../lib/tmdbImage'
import { backdropSrcSet, tmdbSized } from '../lib/tmdbImage'
import { cx, formatDate } from '../lib/utils'
import { useMediaActions } from '../store'
import { useToast } from './Toast'
@@ -172,7 +172,6 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
else images.current.delete(it.id)
}}
src={it.backdrop ? tmdbSized(image, 'w1280') : image}
crossOrigin={imgCors(it.backdrop ? tmdbSized(image, 'w1280') : image)}
srcSet={it.backdrop ? backdropSrcSet(image) : undefined}
sizes="(min-width: 64rem) 60vw, 100vw"
alt=""
@@ -254,7 +253,7 @@ export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item:
return (
<article className="flex h-[5.5rem] w-72 shrink-0 overflow-hidden rounded-md border border-line bg-surface">
<button {...prefetchAttrs(item)} onClick={() => onOpen(item)} className="flex min-w-0 flex-1 items-stretch text-start" aria-label={t('card.open', { title: item.title })}>
<span className="block w-[3.6rem] shrink-0 bg-surface-2">{image && <img src={image} crossOrigin={imgCors(image)} alt="" loading="lazy" decoding="async" className="size-full object-cover" />}</span>
<span className="block w-[3.6rem] shrink-0 bg-surface-2">{image && <img src={image} alt="" loading="lazy" decoding="async" className="size-full object-cover" />}</span>
<span className="flex min-w-0 flex-1 flex-col justify-center px-3">
<span className="block truncate font-bold text-base leading-tight">{item.title}</span>
<span className="mt-0.5 block truncate text-xs text-ink-3">
+1 -2
View File
@@ -1,5 +1,4 @@
import { locale, t } from '../i18n'
import { imgCors } from '../lib/tmdbImage'
import { ArrowLeft, Check, Pencil, Plus, Search, Trash2 } from 'lucide-react'
import { useMemo, useState } from 'react'
import { cx, normalizeText } from '../lib/utils'
@@ -21,7 +20,7 @@ function Mosaic({ items }: { items: MediaItem[] }) {
<div className="grid grid-cols-2 gap-0.5 overflow-hidden rounded-xl border border-line bg-surface-2">
{cells.map((item, i) =>
item?.poster ? (
<img key={i} src={item.poster} crossOrigin={imgCors(item.poster)} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
<img key={i} src={item.poster} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
) : (
<div key={i} className="aspect-[2/3] w-full bg-surface-2" />
),
-2
View File
@@ -1,5 +1,4 @@
import { useState } from 'react'
import { imgCors } from '../lib/tmdbImage'
import { cx } from '../lib/utils'
/** Affiche du média, ou une vignette sobre (aplat + initiale en serif) si aucune image. */
@@ -10,7 +9,6 @@ export default function Poster({ src, title, className }: { src?: string; title:
return (
<img
src={src}
crossOrigin={imgCors(src)}
alt={title}
loading="lazy"
decoding="async"
+1 -2
View File
@@ -1,5 +1,4 @@
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
import { imgCors } from '../../lib/tmdbImage'
import { useEffect, useMemo, useState } from 'react'
import { t } from '../../i18n'
import { useBackToClose } from '../../lib/backNav'
@@ -108,7 +107,7 @@ export default function PersonSheet({
<div className="flex items-start gap-4 lg:gap-8">
<div className="w-28 shrink-0 lg:w-48">
{photo ? (
<img src={photo} crossOrigin={imgCors(photo)} alt={name} className="aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover" />
<img src={photo} alt={name} className="aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover" />
) : (
<div className="grid aspect-[2/3] w-full place-items-center rounded-xl border border-line bg-surface-2 text-4xl font-bold text-ink-3" aria-hidden="true">
{name.charAt(0) || '?'}
+1 -2
View File
@@ -1,5 +1,4 @@
import { Check, Loader2, LogOut, Pencil, Plus, Search, Trash2, UserPlus, Users, X } from 'lucide-react'
import { imgCors } from '../../lib/tmdbImage'
import { useEffect, useMemo, useState } from 'react'
import { locale, t } from '../../i18n'
import {
@@ -43,7 +42,7 @@ function PosterMosaic({ posters }: { posters: string[] }) {
<div className="relative grid grid-cols-2 gap-0.5 overflow-hidden rounded-xl border border-line bg-surface-2">
{[0, 1, 2, 3].map((i) =>
posters[i] ? (
<img key={i} src={posters[i]} crossOrigin={imgCors(posters[i])} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
<img key={i} src={posters[i]} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
) : (
<div key={i} className="aspect-[2/3] w-full bg-surface-2" />
),
+2 -3
View File
@@ -1,5 +1,4 @@
import { Check, Loader2, PenLine, Search, X } from 'lucide-react'
import { imgCors } from '../../lib/tmdbImage'
import { useEffect, useRef, useState, type ReactNode } from 'react'
import { t } from '../../i18n'
import { useBackToClose } from '../../lib/backNav'
@@ -101,7 +100,7 @@ export default function AddTitle({
<li key={r.externalId}>
<button data-prefetch={r.externalId} onClick={() => (mine ? onOpenItem(mine) : onPick(r))} className="flex w-full items-center gap-3 py-3 text-start active:bg-surface lg:border-b lg:border-line">
{r.thumb ? (
<img src={r.thumb} crossOrigin={imgCors(r.thumb)} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
<img src={r.thumb} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
) : (
<span className="grid h-[5.25rem] w-14 shrink-0 place-items-center rounded-lg border border-line bg-surface-2 font-semibold text-ink-3">{r.title.charAt(0)}</span>
)}
@@ -129,7 +128,7 @@ export default function AddTitle({
<li key={p.id}>
<button onClick={() => onOpenPerson(p)} className="flex w-full items-center gap-3 py-2.5 text-start active:bg-surface lg:border-b lg:border-line">
{p.photo ? (
<img src={p.photo} crossOrigin={imgCors(p.photo)} alt="" loading="lazy" className="size-14 shrink-0 rounded-full border border-line bg-surface-2 object-cover" />
<img src={p.photo} alt="" loading="lazy" className="size-14 shrink-0 rounded-full border border-line bg-surface-2 object-cover" />
) : (
<span className="grid size-14 shrink-0 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3">{p.name.charAt(0)}</span>
)}
+2 -3
View File
@@ -12,7 +12,7 @@ import { useEscape } from '../../lib/escape'
import { episodeCap, seasonPosition } from '../../lib/franchise'
import { episodesPatch } from '../../lib/progress'
import { useScrollLock } from '../../lib/scrollLock'
import { backdropSrcSet, tmdbSized, imgCors } from '../../lib/tmdbImage'
import { backdropSrcSet, tmdbSized } from '../../lib/tmdbImage'
import { cx, formatDate, formatDuration, formatRating, todayISO } from '../../lib/utils'
import { GuestError, useMedia } from '../../store'
import { allTags, cleanTag } from '../../lib/bulk'
@@ -385,7 +385,6 @@ export default function TitleSheet({ item: initial, seed, onClose, onOpenPerson,
{heroImage ? (
<img
src={tmdbSized(heroImage, 'w1280')}
crossOrigin={imgCors(tmdbSized(heroImage, 'w1280'))}
srcSet={backdropSrcSet(heroImage)}
sizes="100vw"
alt=""
@@ -659,7 +658,7 @@ export default function TitleSheet({ item: initial, seed, onClose, onOpenPerson,
className="group w-[5.5rem] shrink-0 text-center"
>
{c.photo ? (
<img src={c.photo} crossOrigin={imgCors(c.photo)} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover transition-colors group-hover:border-accent" />
<img src={c.photo} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover transition-colors group-hover:border-accent" />
) : (
<span className="mx-auto grid size-20 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3 transition-colors group-hover:border-accent">{c.name.charAt(0)}</span>
)}
+2 -3
View File
@@ -2,7 +2,7 @@ import { ChevronDown, ExternalLink, Globe } from 'lucide-react'
import { useMemo, type ReactNode } from 'react'
import { t } from '../../i18n'
import type { TitleExtras } from '../../lib/catalogApi'
import { tmdbSized, imgCors } from '../../lib/tmdbImage'
import { tmdbSized } from '../../lib/tmdbImage'
import { countryName, defaultWatchRegion, OFFER_KINDS, setWatchRegion, useWatchRegion, type StreamLink, type WatchProvider } from '../../lib/watchProviders'
const JUSTWATCH = 'https://www.justwatch.com'
@@ -96,7 +96,6 @@ function ProviderLogo({ provider, href }: { provider: WatchProvider; href?: stri
const logo = provider.logo ? (
<img
src={provider.logo}
crossOrigin={imgCors(provider.logo)}
srcSet={`${provider.logo} 1x, ${tmdbSized(provider.logo, 'w154')} 2x`}
alt={provider.name}
title={provider.name}
@@ -133,7 +132,7 @@ function StreamLinks({ links }: { links: StreamLink[] }) {
>
{l.icon ? (
<span className="grid size-7 shrink-0 place-items-center rounded-full bg-surface-2" style={l.color ? { backgroundColor: l.color } : undefined}>
<img src={l.icon} crossOrigin={imgCors(l.icon)} alt="" loading="lazy" className="size-4 object-contain" />
<img src={l.icon} alt="" loading="lazy" className="size-4 object-contain" />
</span>
) : (
<span className="grid size-7 shrink-0 place-items-center rounded-full bg-surface-2 text-xs font-semibold text-ink-2" aria-hidden>
-3
View File
@@ -1,5 +1,4 @@
import type { MediaInput, MediaType } from '../types'
import { imgCors } from './tmdbImage'
import { region, t, tmdbLanguage } from '../i18n'
import { ratingsViaCloud, tmdbViaCloud } from './cloud/api'
import { TYPE_BY_VALUE } from './constants'
@@ -447,8 +446,6 @@ export function preloadImages(urls: (string | undefined)[]): void {
const img = new Image()
img.decoding = 'async'
img.referrerPolicy = 'no-referrer'
const cors = imgCors(url) // même mode que l'image affichée ensuite (sinon deux téléchargements)
if (cors) img.crossOrigin = cors
img.src = url
}
}
-8
View File
@@ -16,11 +16,3 @@ export function backdropSrcSet(url: string | undefined): string | undefined {
if (!url || !TMDB_SIZED.test(url)) return undefined
return `${tmdbSized(url, 'w780')} 780w, ${tmdbSized(url, 'w1280')} 1280w, ${tmdbSized(url, 'original')} 1920w`
}
/**
* Images TMDB et AniList demandées en mode CORS (ces deux serveurs l'autorisent). Sans cela, la copie gardée
* hors-ligne est « opaque » : Chrome la compte pour ~7 Mo de quota chacune, et des centaines d'affiches
* finissaient par dépasser l'espace de l'app (au risque d'effacer aussi la bibliothèque enregistrée sur l'appareil).
*/
export const imgCors = (src: string | undefined): 'anonymous' | undefined =>
src && /^https:\/\/(image\.tmdb\.org|s4\.anilist\.co)\//.test(src) ? 'anonymous' : undefined
+2 -2
View File
@@ -23,9 +23,9 @@ installFriendlyNetworkErrors()
// Service worker : cache l'app pour un fonctionnement hors-ligne et la met à jour automatiquement.
registerSW({ immediate: true })
// Anciennes copies d'images « opaques » (~7 Mo de quota chacune) : remplacées par posters-v2 / backdrops-v2
// Caches d'images d'un essai abandonné (images en mode CORS, cassées sur iPhone) : supprimés
try {
for (const name of ['posters', 'backdrops']) void caches.delete(name).catch(() => {})
for (const name of ['posters-v2', 'backdrops-v2']) void caches.delete(name).catch(() => {})
} catch {
/* Cache API indisponible */
}