Skip to content

Feat 3139 self hosted multi regions support - #3150

Open
ibaraki-douji wants to merge 5 commits into
appwrite:mainfrom
ibaraki-douji:feat-3139-self-hosted-multi-regions-support
Open

Feat 3139 self hosted multi regions support#3150
ibaraki-douji wants to merge 5 commits into
appwrite:mainfrom
ibaraki-douji:feat-3139-self-hosted-multi-regions-support

Conversation

@ibaraki-douji

Copy link
Copy Markdown

What does this PR do?

Adds self-hosted multi-region console support so operators can run one apex console against a meta API plus regional APIs, without Cloud-only gates or rebuilding the image when regions change.

  • isMultiRegion from PUBLIC_APPWRITE_MULTI_REGION=true (alongside existing isMultiRegionSupported for Cloud).
  • Runtime region catalog via GET /console/regions (nginx exact location + optional ConfigMap/volume mount). Accepts a JSON array or { "regions": [...] } with $id, name, disabled, available, optional flag, and optional routing fields:
    • hostname{page-protocol}//{hostname}/v1
    • endpoint → full API base (with or without /v1)
  • Self-hosted API routing (not Cloud subdomain rewrite):
    • single-region / meta: same hostname as the page + /v1 (leave PUBLIC_APPWRITE_ENDPOINT empty)
    • multi-region regional calls: only catalog hostname / endpoint
    • Cloud: unchanged {region}. subdomain behavior
  • Create + onboarding: show region picker and send region when multi-region is on (self-hosted modal, not Cloud wizard).
  • Org UI: show region name on project cards when multi-region is enabled.
  • getProjectEndpoint: uses getApiEndpoint(region) so copy/display URLs match SDK routing.
  • Unit tests: src/lib/helpers/regionHosts.test.ts for endpoint vs hostname vs null fallback.
  • .env.example: documents empty PUBLIC_APPWRITE_ENDPOINT for self-hosted (no hostname baked into the image).

Self-hosted operators configure hosts at deploy time via /console/regions; they do not need to rebuild the console image per environment.

Test Plan

  • bun format / bun run check / bun run lint / bun run test:unit -- src/lib/helpers/regionHosts.test.ts
  • Confirm built image has no baked appwrite.localhost / fra.localhost / nyc.localhost / absolute http://…localhost/v1 (empty PUBLIC_APPWRITE_ENDPOINT)
  • Single-region SH: PUBLIC_APPWRITE_MULTI_REGION=false, console on localhost → API calls go to http://localhost/v1; register/login works
  • Multi-region SH: PUBLIC_APPWRITE_MULTI_REGION=true + ConfigMap at /console/regions with hostname → region picker, create project in fra/nyc, SDK hits regional hosts; meta stays on page hostname
  • Cloud path unchanged when PUBLIC_CONSOLE_MODE=cloud (subdomain rewrite still applies)

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines?
  • Branch follows TYPE-ISSUE_ID-DESCRIPTION (feat-3139-self-hosted-multi-regions-support)

@ibaraki-douji
ibaraki-douji marked this pull request as ready for review August 6, 2026 21:06
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds runtime-configurable multi-region support for self-hosted consoles while preserving Cloud routing.

  • Loads and validates a same-origin runtime region catalog before regional SDK calls.
  • Routes regional API and displayed project endpoints through catalog-provided hosts.
  • Adds self-hosted region selection to project creation and region labels to project cards.
  • Uses the current page origin for self-hosted API calls when no explicit endpoint is configured.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/routes/(console)/regions.ts Adds validated, cached runtime catalog loading with propagated failures and retry support.
src/routes/(console)/+layout.ts Ensures self-hosted region routing data is initialized before descendant console loads.
src/lib/helpers/apiEndpoint.ts Separates catalog-based self-hosted routing from existing Cloud subdomain routing.
src/lib/helpers/regionHosts.ts Introduces the in-memory region-to-endpoint catalog used by SDK endpoint resolution.
src/routes/(console)/organization-[organization]/createProject.svelte Adds self-hosted regional project selection and includes the selected region in creation requests.
.env.example Changes the self-hosted endpoint default to use same-origin runtime resolution.

Reviews (5): Last reviewed commit: "chore(env): Revert PUBLIC_APPWRITE_ENDPO..." | Re-trigger Greptile

Comment thread src/lib/helpers/apiEndpoint.ts
Comment thread .env.example
Comment thread src/routes/(console)/regions.ts
Comment thread .env.example Outdated
@ibaraki-douji
ibaraki-douji force-pushed the feat-3139-self-hosted-multi-regions-support branch from 6f53438 to 2447975 Compare August 7, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Self-hosted multi-region console (region picker + runtime regions catalog)

1 participant