From 22aac5c4442e72f9f14eb809fb3b82154a8a5399 Mon Sep 17 00:00:00 2001 From: Przemek Wiech Date: Mon, 20 Jan 2020 18:39:08 +0100 Subject: [PATCH] WikiTree: Use cors-anywhere only if hosted outside of apps.wikitree.com --- src/app.tsx | 2 +- src/wikitree.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 5200c5e..8ff04ee 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -264,7 +264,7 @@ export class App extends React.Component { ); const data = source === 'wikitree' - ? await loadWikiTree(indi!, handleCors) + ? await loadWikiTree(indi!) : hash ? await loadGedcom(hash, gedcom, images) : await loadFromUrl(url!, handleCors); diff --git a/src/wikitree.ts b/src/wikitree.ts index eecf060..1c75c46 100644 --- a/src/wikitree.ts +++ b/src/wikitree.ts @@ -94,10 +94,10 @@ async function getRelatives(keys: string[], handleCors: boolean) { * Loads data from WikiTree to populate an hourglass chart starting from the * given person ID. */ -export async function loadWikiTree( - key: string, - handleCors: boolean, -): Promise { +export async function loadWikiTree(key: string): Promise { + // Work around CORS if not in apps.wikitree.com domain. + const handleCors = window.location.hostname !== 'apps.wikitree.com'; + const everyone: Person[] = []; // Fetch the ancestors of the input person and ancestors of his/her spouses.