From 0ed2ebd5c20fcbb67ff1b3260a145347168e45e1 Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Tue, 29 Oct 2024 19:57:44 +0100 Subject: [PATCH] Update docs --- .env.example | 3 +-- README.md | 11 +++++++---- dist/immich.js | 6 +++--- docker-compose.yml | 2 +- src/immich.ts | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.env.example b/.env.example index 7a87529..fbe85ab 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ IMMICH_URL=http://localhost:2283 API_KEY="Get this from your Immich Account Settings page" -SERVER_URL=https://shared.example.com -SERVER_PORT=3000 +PORT=3000 CACHE_AGE=2592000 diff --git a/README.md b/README.md index 5559736..5dfc088 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Immich Public Proxy +Share your Immich photos and albums in a safe way without exposing your Immich instance to the public. + +[Live demo](https://share.alan.gr/share/UiOulNielojwHbS0IJi5blwBOFzYC18CuPVtU23Bl3XK5YNVkbRONRT-HOTMQSMgdNs) +

@@ -28,13 +32,12 @@ git clone https://github.com/alangrainger/immich-public-proxy.git ``` IMMICH_URL=http://localhost:2283 API_KEY="Get this from your Immich Account Settings page" -SERVER_URL=https://shared.example.com -SERVER_PORT=3000 +PORT=3000 CACHE_AGE=2592000 ``` - `IMMICH_URL` is the URL to access Immich in your local network. This is not your public URL. -- `SERVER_URL` will be the public URL for accessing this Immich Public Proxy app. +- `API_KEY` get this from the Account Settings page of your Immich user account - `CACHE_AGE` by default, assets will be cached for 30 days. Set this to 0 to disable caching. 3. Start the docker container: @@ -43,7 +46,7 @@ CACHE_AGE=2592000 docker-compose up -d ``` -4. Set the "External domain" in your Immich **Server Settings** to be the same as your `SERVER_URL`: +4. Set the "External domain" in your Immich **Server Settings** to be the same as the public URL for your Immich Public Proxy: diff --git a/dist/immich.js b/dist/immich.js index c01605c..084b3b0 100644 --- a/dist/immich.js +++ b/dist/immich.js @@ -77,13 +77,13 @@ class Immich { * Return the image data URL for a photo */ photoUrl(key, id, size) { - return `${process.env.SERVER_URL}/photo/${key}/${id}` + (size ? `?size=${size}` : ''); + return `/photo/${key}/${id}` + (size ? `?size=${size}` : ''); } /** * Return the video data URL for a video */ videoUrl(key, id) { - return `${process.env.SERVER_URL}/video/${key}/${id}`; + return `/video/${key}/${id}`; } /** * Check if a provided ID matches the Immich ID format @@ -100,4 +100,4 @@ class Immich { } const immich = new Immich(); exports.default = immich; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBaUU7QUFDakUsMERBQXlCO0FBRXpCLE1BQU0sTUFBTTtJQUNWOzs7T0FHRztJQUNHLE9BQU8sQ0FBRSxRQUFnQjs7WUFDN0IsTUFBTSxHQUFHLEdBQUcsTUFBTSxLQUFLLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLEdBQUcsTUFBTSxHQUFHLFFBQVEsRUFBRTtnQkFDbEUsT0FBTyxFQUFFO29CQUNQLFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sSUFBSSxFQUFFO2lCQUN2QzthQUNGLENBQUMsQ0FBQTtZQUNGLElBQUksR0FBRyxDQUFDLE1BQU0sS0FBSyxHQUFHLEVBQUUsQ0FBQztnQkFDdkIsTUFBTSxXQUFXLEdBQUcsR0FBRyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxDQUFBO2dCQUN6RCxJQUFJLFdBQVcsQ0FBQyxRQUFRLENBQUMsa0JBQWtCLENBQUMsRUFBRSxDQUFDO29CQUM3QyxPQUFPLEdBQUcsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtnQkFDbkIsQ0FBQztxQkFBTSxDQUFDO29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3NpemV9YCA6ICcnKVxuICB9XG5cbiAgLyoqXG4gICAqIFJldHVybiB0aGUgdmlkZW8gZGF0YSBVUkwgZm9yIGEgdmlkZW9cbiAgICovXG4gIHZpZGVvVXJsIChrZXk6IHN0cmluZywgaWQ6IHN0cmluZykge1xuICAgIHJldHVybiBgL3ZpZGVvLyR7a2V5fS8ke2lkfWBcbiAgfVxuXG4gIC8qKlxuICAgKiBDaGVjayBpZiBhIHByb3ZpZGVkIElEIG1hdGNoZXMgdGhlIEltbWljaCBJRCBmb3JtYXRcbiAgICovXG4gIGlzSWQgKGlkOiBzdHJpbmcpIHtcbiAgICByZXR1cm4gISFpZC5tYXRjaCgvXlswLTlhLWZdezh9LVswLTlhLWZdezR9LVswLTlhLWZdezR9LVswLTlhLWZdezR9LVswLTlhLWZdezEyfSQvKVxuICB9XG5cbiAgLyoqXG4gICAqIENoZWNrIGlmIGEgcHJvdmlkZWQga2V5IG1hdGNoZXMgdGhlIEltbWljaCBzaGFyZWQtbGluayBrZXkgZm9ybWF0XG4gICAqL1xuICBpc0tleSAoa2V5OiBzdHJpbmcpIHtcbiAgICByZXR1cm4gISFrZXkubWF0Y2goL15bXFx3LV0rJC8pXG4gIH1cbn1cblxuY29uc3QgaW1taWNoID0gbmV3IEltbWljaCgpXG5cbmV4cG9ydCBkZWZhdWx0IGltbWljaFxuIl19 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bda0069..cebae78 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: volumes: - ./:/home/node/app:Z ports: - - ${SERVER_PORT}:3000 + - ${PORT}:3000 command: bash -c "cd /home/node/app && npm install && npm start" restart: always healthcheck: diff --git a/src/immich.ts b/src/immich.ts index 6dcf5a3..d8eba8e 100644 --- a/src/immich.ts +++ b/src/immich.ts @@ -69,14 +69,14 @@ class Immich { * Return the image data URL for a photo */ photoUrl (key: string, id: string, size?: ImageSize) { - return `${process.env.SERVER_URL}/photo/${key}/${id}` + (size ? `?size=${size}` : '') + return `/photo/${key}/${id}` + (size ? `?size=${size}` : '') } /** * Return the video data URL for a video */ videoUrl (key: string, id: string) { - return `${process.env.SERVER_URL}/video/${key}/${id}` + return `/video/${key}/${id}` } /**