diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2021-02-07 12:54:20 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2021-02-07 15:00:07 +0000 |
| commit | c5013103d6a81c8ad17914b0334cd1061c268af2 (patch) | |
| tree | f580f55dbddac9a91921137e2037a20954ff455b /src | |
| parent | Mastodon semi-compatibility (diff) | |
| download | fedidag-c5013103d6a81c8ad17914b0334cd1061c268af2.tar.gz fedidag-c5013103d6a81c8ad17914b0334cd1061c268af2.zip | |
include CORS proxy nginx config
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js index 1169307..ba50149 100644 --- a/src/index.js +++ b/src/index.js @@ -13,6 +13,11 @@ const context = [ }, ]; + +const corsOrigin = process.env.CORS_ORIGIN || location.origin; +console.log(corsOrigin); +const cors = (url) => `${corsOrigin}/remote/${url}`; + function wrapCache(target) { const orig = target.descriptor.value; @@ -45,7 +50,7 @@ class GraphContainer extends Component { @wrapCache async loadCollection(id, ...args) { - const collection = await jsonld.compact(`http://localhost:8088/${id}`, context); + const collection = await jsonld.compact(cors(id), context); let items = []; const addItems = (i) => { @@ -61,11 +66,11 @@ class GraphContainer extends Component { } else { let page = collection.first; const seen = []; - while (seen.indexOf(page.id) < 0) { + while (page && seen.indexOf(page.id) < 0) { seen.push(page.id); addItems(page.items); - page = await jsonld.compact(`http://localhost:8088/${page.next}`, context); + page = page.next && await jsonld.compact(cors(page.next), context); } } @@ -76,7 +81,7 @@ class GraphContainer extends Component { @wrapCache async loadNote(id, items) { const item = await jsonld.frame( - `http://localhost:8088/${id}`, + cors(id), { '@context': context, type: 'Note', |
