Problem/Motivation
A consumer can override an exposed setting such as system.site:page.front, but only the /jsonapi/decoupled/settings resource applies the override. Decoupled Router reads its configuration straight from the config factory, so a consumer with its own front page reads that front page from Decoupled Settings while /router/translate-path?path=/ still resolves the site's front page.
I've proposed a per-request configuration service for Decoupled Router in 3611692, and this issue depends on it.
Proposed resolution
- Move the consumer lookup out of
SettingsResource::consumerFor()into a service,decoupled_settings.consumer_identifier, with the same rules: theX-Consumer-IDheader first, then theconsumerIdquery parameter, matched onclient_id. - Add
SettingsResolver::get(?ConsumerInterface $consumer, string $key, CacheableMetadata $cacheability): mixedfor one key. It applies the same exposure list and excluded keys asresolve(). The router then uses exactly the values a frontend can read. - When Decoupled Router is enabled, decorate
decoupled_router.configfrom a service provider. For an exposed key with an override on the consumer, the decorator returns the override, and for any other key it returns the inner service's value. It adds both consumer cache contexts and the consumer and config cache tags. - Document in the README that overriding a router setting per consumer, such as
absolute_resolved_urls, needsdecoupled_router.settingsin the exposure list, and that this also makes it readable at/jsonapi/decoupled/settings, while the front page works without it becausesystem.siteis exposed by default.
Remaining tasks
- Functional tests with Page Cache and Dynamic Page Cache on, where consumer A, consumer B and no consumer each get their own answer for
path=/. - Postponed until 3611692 is merged.
User interface changes
None.
API changes
A new decoupled_settings.consumer_identifier service and a new SettingsResolver::get() method.
Data model changes
None.
Comments