mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-18 10:13:43 +08:00
fix: Use a proxy for external URL fetches to avoid CORS issues.
This commit is contained in:
@@ -103,7 +103,13 @@ export function parseSourcesFromJson(jsonString: string): ImportResult {
|
||||
* Fetch and parse sources from a URL
|
||||
*/
|
||||
export async function fetchSourcesFromUrl(url: string): Promise<ImportResult> {
|
||||
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',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user