diff --git a/src/imgproxy/loader.ts b/src/imgproxy/loader.ts index dea597c..0c38c74 100644 --- a/src/imgproxy/loader.ts +++ b/src/imgproxy/loader.ts @@ -2,10 +2,12 @@ import { urlSafeBase64 } from './utils'; import { ImageLoaderProps } from 'next/image'; const imgProxyLoader = - (pathSegment: string = '_image') => + (pathSegment: string = '_image', whitelistedSourceUrls: string[]) => ({ src, width, quality }: ImageLoaderProps) => { - // If the source is not an S3 URL, return the original source - if (!src.startsWith('s3://')) return src; + // if the source url is not whitelisted, return the original src + if (!whitelistedSourceUrls.some((url) => src.startsWith(url))) { + return src; + } const encodedUrl = urlSafeBase64(src); const params = new URLSearchParams();