From 80d99626c4d2ea1a56b7d8732915728048b30c18 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Thu, 25 Dec 2025 17:20:51 +0800 Subject: [PATCH] fix: Use a proxy for external URL fetches to avoid CORS issues. --- lib/utils/source-import-utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/utils/source-import-utils.ts b/lib/utils/source-import-utils.ts index 388bda1..c3b0ac1 100644 --- a/lib/utils/source-import-utils.ts +++ b/lib/utils/source-import-utils.ts @@ -103,7 +103,13 @@ export function parseSourcesFromJson(jsonString: string): ImportResult { * Fetch and parse sources from a URL */ export async function fetchSourcesFromUrl(url: string): Promise { - const response = await fetch(url, { + // If we're in the browser and it's an external URL, use our proxy to avoid CORS issues + const isExternal = url.startsWith('http') && (typeof window !== 'undefined' && !url.includes(window.location.host)); + const fetchUrl = isExternal + ? `/api/proxy?url=${encodeURIComponent(url)}` + : url; + + const response = await fetch(fetchUrl, { headers: { 'Accept': 'application/json', },