Skip to content

Commit efce527

Browse files
authored
fix: enable header-based tenant routing for demo and register CurrentAccountService (#1248)
Cloudflare does not proxy *.demo.meridianhub.cloud subdomains, so the production subdomain-based transport fails with 503 in the demo env. Switch to header-based routing (X-Tenant-Slug) when VITE_DEMO_MODE is set, matching dev mode behaviour. Requires LOCAL_DEV_MODE=true on the demo server (already applied). Separately, CurrentAccountService was excluded from the Vanguard transcoder due to REST route conflicts with InternalAccountService. The comment claimed it was "still reachable via Connect protocol" but this was incorrect — unregistered services are 404 for all HTTP protocols. Adding it to serviceNames allows Connect-protocol requests to route correctly; REST lien routes continue to resolve to InternalAccountService (registered first). Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 2556990 commit efce527

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

cmd/meridian/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,11 @@ var serviceNames = []string{
745745
"meridian.financial_accounting.v1.FinancialAccountingService",
746746
"meridian.position_keeping.v1.PositionKeepingService",
747747
"meridian.forecasting.v1.ForecastingService",
748-
// CurrentAccountService excluded from Vanguard: its REST routes (/v1/liens/*)
749-
// conflict with InternalAccountService. Still reachable via Connect protocol
750-
// (/{package}.{Service}/{Method} paths don't conflict).
748+
// CurrentAccountService shares REST routes (/v1/liens/*) with InternalAccountService.
749+
// Vanguard resolves the conflict by routing REST lien requests to whichever service
750+
// was registered first (InternalAccountService above). Connect protocol paths
751+
// (/{package}.{Service}/{Method}) are unique per service and never conflict.
752+
"meridian.current_account.v1.CurrentAccountService",
751753
"meridian.payment_order.v1.PaymentOrderService",
752754
"meridian.reconciliation.v1.AccountReconciliationService",
753755
"meridian.saga.v1.SagaRegistryService",

frontend/src/api/transport.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ export function createTenantTransport(
1212
getToken: TokenGetter,
1313
getTenantSlug: TenantSlugGetter,
1414
): Transport {
15-
// In development, keep the base URL and route via X-Tenant-Slug header
15+
// In development or demo mode, keep the base URL and route via X-Tenant-Slug header
1616
// (the gateway's LOCAL_DEV_MODE resolves tenants from the header).
1717
// In production, use subdomain-based URL for tenant routing.
18+
const useHeaderRouting =
19+
import.meta.env.DEV || import.meta.env.VITE_DEMO_MODE === 'true'
1820
const baseUrl =
19-
tenantSlug && !import.meta.env.DEV ? buildTenantBaseUrl(tenantSlug) : apiConfig.baseUrl
21+
tenantSlug && !useHeaderRouting ? buildTenantBaseUrl(tenantSlug) : apiConfig.baseUrl
2022

2123
return createConnectTransport({
2224
baseUrl,

0 commit comments

Comments
 (0)