From f9f868f0254d5c31e3281bb71dfdbd9b5aedda3b Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Thu, 31 Oct 2024 07:09:11 +0100 Subject: [PATCH] Removed API key requirement thanks to #3 --- README.md | 4 ++-- dist/immich.js | 8 ++------ src/immich.ts | 6 +----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 15cfed4..a1f2220 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ When the proxy receives a request, it will come as a link like this: https://your-proxy-url.com/share/ffSw63qnIYMtpmg0RNvOui0Dpio7BbxsObjvH8YZaobIjIAzl5n7zTX5d6EDHdOYEvo ``` -The part after `/share/` is Immich's shared link public ID (called the `key` [in the docs](https://immich.app/docs/api/get-all-shared-links/)). +The part after `/share/` is Immich's shared link public ID (called the `key` [in the docs](https://immich.app/docs/api/get-my-shared-link)). **Immich Public Proxy** takes that key and makes an API call to your Immich instance over your local network, to ask what photos or videos are shared in that share URL. @@ -70,7 +70,7 @@ photos or videos are shared in that share URL. If it is a valid share URL, the proxy fetches just those assets via local API and returns them to the visitor as an individual image or gallery. -If the shared link is expired or any of the assets have been put in the Immich trash, it will not return those. +If the shared link has expired or any of the assets have been put in the Immich trash, it will not return those. ## Configuration diff --git a/dist/immich.js b/dist/immich.js index 830e2fe..5f0fbf8 100644 --- a/dist/immich.js +++ b/dist/immich.js @@ -11,11 +11,7 @@ class Immich { */ request(endpoint) { return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield fetch(process.env.IMMICH_URL + '/api' + endpoint, { - headers: { - 'x-api-key': process.env.API_KEY || '' - } - }); + const res = yield fetch(process.env.IMMICH_URL + '/api' + endpoint); if (res.status === 200) { const contentType = res.headers.get('Content-Type') || ''; if (contentType.includes('application/json')) { @@ -105,4 +101,4 @@ class Immich { } const immich = new Immich(); exports.default = immich; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdC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cpIHtcbiAgICByZXR1cm4gISFpZC5tYXRjaCgvXlswLTlhLWZdezh9LVswLTlhLWZdezR9LVswLTlhLWZdezR9LVswLTlhLWZdezR9LVswLTlhLWZdezEyfSQvKVxuICB9XG5cbiAgLyoqXG4gICAqIENoZWNrIGlmIGEgcHJvdmlkZWQga2V5IG1hdGNoZXMgdGhlIEltbWljaCBzaGFyZWQtbGluayBrZXkgZm9ybWF0XG4gICAqL1xuICBpc0tleSAoa2V5OiBzdHJpbmcpIHtcbiAgICByZXR1cm4gISFrZXkubWF0Y2goL15bXFx3LV0rJC8pXG4gIH1cbn1cblxuY29uc3QgaW1taWNoID0gbmV3IEltbWljaCgpXG5cbmV4cG9ydCBkZWZhdWx0IGltbWljaFxuIl19 \ No newline at end of file diff --git a/src/immich.ts b/src/immich.ts index 50fd53f..c310e6b 100644 --- a/src/immich.ts +++ b/src/immich.ts @@ -8,11 +8,7 @@ class Immich { * the possible attack surface of this app. */ async request (endpoint: string) { - const res = await fetch(process.env.IMMICH_URL + '/api' + endpoint, { - headers: { - 'x-api-key': process.env.API_KEY || '' - } - }) + const res = await fetch(process.env.IMMICH_URL + '/api' + endpoint) if (res.status === 200) { const contentType = res.headers.get('Content-Type') || '' if (contentType.includes('application/json')) {