Skip to content

ix(db-sync): support comma-separated DB_SYNC_BASE_URL for multi-origin access - #12908

Open
SSamDav wants to merge 6 commits into
logseq:masterfrom
SSamDav:master
Open

ix(db-sync): support comma-separated DB_SYNC_BASE_URL for multi-origin access#12908
SSamDav wants to merge 6 commits into
logseq:masterfrom
SSamDav:master

Conversation

@SSamDav

@SSamDav SSamDav commented Jul 15, 2026

Copy link
Copy Markdown

Problem

When running a self-hosted db-sync server accessible via multiple addresses (e.g. http://192.168.1.x:8787 on LAN and https://logseq.tailscale-domain via a Tailscale/nginx proxy), only one address could be configured in DB_SYNC_BASE_URL. Clients connecting via a different address would have their request URLs reconstructed with the wrong host, breaking sync.

Fixes: logseq/db-test#1011

Solution

Allow DB_SYNC_BASE_URL to accept a comma-separated list of URLs:

DB_SYNC_BASE_URL=http://192.168.1.74:8787,https://logseq.tailscale-domain

The server now matches the incoming request's Host header against all configured origins and picks the right scheme://host pair for URL reconstruction. Falls back to the first configured origin if no match is found.

Changes

  • config.cljs: parse DB_SYNC_BASE_URL into :base-urls vector; keep :base-url as the first entry for backwards compatibility
  • server.cljs: request-origin-opts returns a vector of {:scheme :host} maps; add parse-url-origin helper
  • platform/node.cljs: request-from-node accepts the origins vector and matches the incoming Host header to pick the right scheme+host
  • node_server_test.cljs: update test to reflect new behaviour

Backwards compatibility

Single-URL config (DB_SYNC_BASE_URL=http://....) continues to work unchanged.

SSamDav added 3 commits July 14, 2026 20:38
…in access

Allow DB_SYNC_BASE_URL to be a comma-separated list of URLs so the
self-hosted sync server accepts requests arriving via different addresses
(e.g. LAN IP over HTTP and a Tailscale/nginx domain over HTTPS) without
running separate server instances.

- config.cljs: parse DB_SYNC_BASE_URL into :base-urls vector; keep
  :base-url as the first entry for backwards compatibility
- server.cljs: request-origin-opts returns a vector of {:scheme :host}
  maps; add parse-url-origin helper
- platform/node.cljs: request-from-node accepts the origins vector and
  matches the incoming Host header to pick the right scheme+host, falling
  back to the first configured origin
- test: update node-server-request-origin test to reflect new behaviour

Fixes: logseq/db-test#1011
fix(db-sync): support comma-separated DB_SYNC_BASE_URL for multi-origin access
@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tiensonqin

Copy link
Copy Markdown
Contributor

@SSamDav Please sign CLA first.

@SSamDav

SSamDav commented Jul 15, 2026

Copy link
Copy Markdown
Author

Signed the CLA

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.

Self-hosted sync: graph UUID tied to server URL, breaking multi-endpoint and IP-change scenarios

3 participants