9 lines
436 B
TypeScript
9 lines
436 B
TypeScript
export function proxyImage(url: string | null | undefined): string | undefined {
|
|
if (!url) return undefined;
|
|
// Already a local path (e.g. cached media) — load it directly. The proxy
|
|
// only knows how to handle Instagram's own CDN hosts, and a relative
|
|
// path has no host at all, so it would otherwise get rejected.
|
|
if (url.startsWith('/')) return url;
|
|
return `/image-proxy?url=${encodeURIComponent(url)}`;
|
|
}
|