Part of Phase 4: Firestore Tenant Routing in Functions. Do a planning review before starting this phase.
Goal
Activate ENABLE_FIRESTORE_TENANT_ROUTING so GET /api/widgets/:provider resolves the user from tenant_hosts Firestore data rather than the WIDGET_USER_ID_BY_HOSTNAME env map. This makes the Functions layer fully dynamic for tenant routing.
Background
The flag ENABLE_FIRESTORE_TENANT_ROUTING already exists in functions/config/backend-config.ts but is not referenced anywhere in the widget resolution path. The tenant_hosts collection is already written by the onboarding flow. This PR closes that loop.
getWidgetUserIdForHostname in functions/config/backend-paths.ts currently only consults the env map. It needs to optionally query tenant_hosts/{hostname} when the flag is enabled.
Tasks
functions/config/backend-paths.ts
functions/config/backend-config.ts
functions/.env.template
Part of Phase 4: Firestore Tenant Routing in Functions. Do a planning review before starting this phase.
Goal
Activate
ENABLE_FIRESTORE_TENANT_ROUTINGsoGET /api/widgets/:providerresolves the user fromtenant_hostsFirestore data rather than theWIDGET_USER_ID_BY_HOSTNAMEenv map. This makes the Functions layer fully dynamic for tenant routing.Background
The flag
ENABLE_FIRESTORE_TENANT_ROUTINGalready exists infunctions/config/backend-config.tsbut is not referenced anywhere in the widget resolution path. Thetenant_hostscollection is already written by the onboarding flow. This PR closes that loop.getWidgetUserIdForHostnameinfunctions/config/backend-paths.tscurrently only consults the env map. It needs to optionally querytenant_hosts/{hostname}when the flag is enabled.Tasks
functions/config/backend-paths.tsgetWidgetUserIdForHostnameto accept adocumentStoreor direct Firestore reference whenfirestoreTenantRoutingEnabledis truetenant_hosts/{hostname}and return the storeduidif foundfunctions/config/backend-config.tsENABLE_FIRESTORE_TENANT_ROUTING=trueas the new defaultfunctions/.env.templateENABLE_FIRESTORE_TENANT_ROUTINGwith description