π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathi2436d2fcaa7e
diff --git a/web/packages/next/origins.ts b/web/packages/next/origins.tsnew file mode 100644index 0000000000..db5b55aef2--- /dev/null+++ b/web/packages/next/origins.ts@@ -0,0 +1,83 @@+import { nullToUndefined } from "@/utils/transform";++/**+ * Return the origin (scheme, host, port triple) that should be used for making+ * API requests to museum.+ *+ * This defaults to {@link defaultAPIOrigin}, but can be overridden when self+ * hosting or developing by setting the `NEXT_PUBLIC_ENTE_ENDPOINT` environment+ * variable.+ */+export const apiOrigin = () => customAPIOrigin() ?? defaultAPIOrigin;++/**+ * Return the overridden API origin, if one is defined by either (in priority+ * order):+ *+ * - Setting the custom server on the landing page (See: [Note: Configuring+ * custom server]); or by+ *+ * - Setting the `NEXT_PUBLIC_ENTE_ENDPOINT` environment variable.+ *+ * Otherwise return undefined.+ */+export const customAPIOrigin = () =>+ nullToUndefined(localStorage.getItem("apiOrigin")) ??+ process.env.NEXT_PUBLIC_ENTE_ENDPOINT ??+ undefined;++/**+ * Default value of {@link apiOrigin}: "https://api.ente.io", Ente's production+ * API servers.+ */+export const defaultAPIOrigin = "https://api.ente.io";++/**+ * Return the origin that should be used for uploading files.+ *+ * This defaults to `https://uploader.ente.io`, serviced by a Cloudflare worker+ * (see infra/workers/uploader). But if a {@link customAPIOrigin} is set then+ * this value is set to the {@link customAPIOrigin} itself, effectively+ * bypassing the Cloudflare worker for non-Ente deployments.+ */+export const uploaderOrigin = () =>+ customAPIOrigin() ?? "https://uploader.ente.io";++/**+ * Return the origin that serves the accounts app.+ *+ * Defaults to our production instance, "https://accounts.ente.io", but can be+ * overridden by setting the `NEXT_PUBLIC_ENTE_ACCOUNTS_URL` environment+ * variable.+ */+export const accountsAppOrigin = () =>+ process.env.NEXT_PUBLIC_ENTE_ACCOUNTS_URL ?? `https://accounts.ente.io`;++/**+ * Return the origin that serves public albums.+ *+ * Defaults to our production instance, "https://albums.ente.io", but can be+ * overridden by setting the `NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT` environment+ * variable.+ */+export const albumsAppOrigin = () =>+ process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT ?? "https://albums.ente.io";++/**+ * Return the origin that serves the family dashboard which can be used to+ * create or manage family plans..+ *+ * Defaults to our production instance, "https://family.ente.io", but can be+ * overridden by setting the `NEXT_PUBLIC_ENTE_FAMILY_URL` environment variable.+ */+export const familyAppOrigin = () =>+ process.env.NEXT_PUBLIC_ENTE_FAMILY_URL ?? "https://family.ente.io";++/**+ * Return the origin that serves the payments app.+ *+ * Defaults to our production instance, "https://payments.ente.io", but can be+ * overridden by setting the `NEXT_PUBLIC_ENTE_PAYMENTS_URL` environment variable.+ */+export const paymentsAppOrigin = () =>+ process.env.NEXT_PUBLIC_ENTE_PAYMENTS_URL ?? "https://payments.ente.io";