Extending the Layout Service
Version:
If you want to customize the output of the Layout Service, you have the following options:
- Extending context data returned by the Layout Service.
- Customizing the Layout Service rendering output.
- Customize the serialization of a Sitecore field.
- Using a custom Layout Service configuration with JSS.
Security considerations
The Layout Service output is not secure and can be inspected client-side. Treat it like an open API, ensuring you are not exposing sensitive or excess data.
When extending Sitecore Context object or building custom Rendering Content Resolvers:
- Only add fields necessary for front-end components. For example, do not inject the entire Sitecore Context object from back-end Sitecore pipelines into the Layout Service response.
- Add data that represents the global app state and must be accessed by multiple components.
- Avoid exposing sensitive information. Be aware of serialization depth to avoid accidentally exposing additional data through complex objects.
If you have suggestions for improving this article, let us know!