Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/utils/imageProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ const WORKER_DOMAIN =
*/
export function getProxiedImageUrl(notionUrl: string): string {
// Return original URL if it's already a local path or external URL
// Only proxy Notion S3 images by host, not by substring match
let host = "";
try {
const parsedUrl = new URL(notionUrl);
host = parsedUrl.host;
} catch {
// If invalid URL, treat as non-proxyable
return notionUrl;
}
if (
!notionUrl ||
notionUrl.startsWith("/") ||
(!notionUrl.includes("s3.us-west-2.amazonaws.com") &&
!notionUrl.includes("prod-files-secure.s3"))
(host !== "s3.us-west-2.amazonaws.com" &&
host !== "prod-files-secure.s3.amazonaws.com")
) {
return notionUrl;
}
Expand Down