From 3e9bbacd2f7f67939c7b77958988adc535717a50 Mon Sep 17 00:00:00 2001
From: Manav Rathi <manav@mrmr.io>
Date: Fri, 12 Apr 2024 11:25:31 +0530
Subject: [PATCH] [docs] Add a FAQ for album sharing on self hosted instances

---
 docs/docs/.vitepress/sidebar.ts       |  4 +++
 docs/docs/self-hosting/faq/sharing.md | 43 +++++++++++++++++++++++++++
 web/apps/photos/.env.development      |  8 ++++-
 3 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 docs/docs/self-hosting/faq/sharing.md

diff --git a/docs/docs/.vitepress/sidebar.ts b/docs/docs/.vitepress/sidebar.ts
index 2d473a4e3..997d692ea 100644
--- a/docs/docs/.vitepress/sidebar.ts
+++ b/docs/docs/.vitepress/sidebar.ts
@@ -207,6 +207,10 @@ export const sidebar = [
                         text: "Verification code",
                         link: "/self-hosting/faq/otp",
                     },
+                    {
+                        text: "Shared albums",
+                        link: "/self-hosting/faq/sharing",
+                    },
                 ],
             },
             {
diff --git a/docs/docs/self-hosting/faq/sharing.md b/docs/docs/self-hosting/faq/sharing.md
new file mode 100644
index 000000000..0ad58e1c0
--- /dev/null
+++ b/docs/docs/self-hosting/faq/sharing.md
@@ -0,0 +1,43 @@
+---
+title: Album sharing
+description: Getting album sharing to work using an self-hosted Ente
+---
+
+# Is public sharing available for self-hosted instances?
+
+Yes.
+
+You'll need to run two instances of the web app, one is regular web app, but
+another one is the same code but running on a different origin (i.e. on a
+different hostname or different port).
+
+Then, you need to tell the regular web app to use your second instance to
+service public links. You can do this by setting the
+`NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT` to point to your second instance when running
+or building the regular web app.
+
+For more details, see
+[.env](https://github.com/ente-io/ente/blob/main/web/apps/photos/.env) and
+[.env.development](https://github.com/ente-io/ente/blob/main/web/apps/photos/.env.development).
+
+As a concrete example, assuming we have a Ente server running on
+`localhost:8080`, we can start two instances of the web app, passing them
+`NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT` that points to the origin
+("scheme://host[:port]") of the second "albums" instance.
+
+The first one, the normal web app
+
+```sh
+NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8080 \
+    NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=http://localhost:3002 \
+    yarn dev:photos
+```
+
+The second one, the same code but acting as the "albums" app (the only
+difference is the port it is running on):
+
+```sh
+NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8080 \
+    NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=http://localhost:3002 \
+    yarn dev:albums
+```
diff --git a/web/apps/photos/.env.development b/web/apps/photos/.env.development
index a8277281d..fd4d63c08 100644
--- a/web/apps/photos/.env.development
+++ b/web/apps/photos/.env.development
@@ -12,8 +12,14 @@
 #NEXT_PUBLIC_ENTE_ENDPOINT = http://localhost:8080
 
 # If you wish to preview how the shared albums work, you can use `yarn
-# dev:albums`. The equivalent CLI command using env vars would be
+# dev:albums`. You'll need to run two instances.
+
+# The equivalent CLI commands using env vars would be:
 #
+#    # For the normal web app
+#     NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8080 NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=http://localhost:3002 yarn dev:photos
+#
+#    # For the albums app
 #     NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8080 NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=http://localhost:3002 yarn dev:albums
 
 #NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT = http://localhost:3002