In a decoupled or headless Drupal site, images and links embedded in
rich-text fields often arrive at the frontend as root-relative paths
like /sites/default/files/image.jpg. React, Angular,
Vue, Next.js and native apps cannot resolve those paths – they
need the full https://example.com/… URL.
REST Absolute URLs rewrites root-relative URLs to absolute URLs in content exposed through JSON:API, REST, and Views REST Export. It runs during serialization only, so standard Drupal page rendering is untouched. No configuration is required for the common case; a single setting handles Docker and SSR environments where Drupal would otherwise detect an internal container hostname.
<img src> and <a href> inside
body fields and other formatted-text fields, both in the raw
value and in the computed processed
output.MarkupInterface values are rewritten before they reach
the encoder.$config['rest_absolute_urls']['base_url'] in
settings.php for Docker, Kubernetes, server-side
rendering or any setup where Drupal cannot detect the public host
reliably.Drupal core's JSON:API serializer leaves embedded URLs as-is. The common workarounds – preprocessing hooks, custom normalizers, or frontend string replacement – are fragile and need to be rewritten for every project. This module solves the problem once, at the serializer level, for every formatted-text field and every Views REST Export row, with no per-field configuration.
| Module | Approach | Best for |
|---|---|---|
| REST Absolute URLs | Serializer-level normalizers rewrite embedded URLs in formatted text and in Views REST Export markup. | Making embedded images and links in rich-text fields usable from any decoupled frontend. |
| Drupal core “Render as absolute URL” option (11.x+) | Per-display checkbox on the URL to file and URL to image field formatters. | Single URL or image URL fields configured per view mode – does not touch URLs embedded in body text. |
| JSON:API Extras | Overrides, aliases and field disablement for JSON:API resource types. | Reshaping the JSON:API payload (field names, visibility, resource paths); orthogonal to URL rewriting. |
| Consumer Image Styles | Exposes image-style derivatives per consumer on image fields in JSON:API. | Serving responsive image derivatives to decoupled consumers; complementary – use together for images in dedicated image fields and images embedded in body copy. |
| Decoupled Router | Resolves friendly frontend paths back to backend entity routes. | Mapping incoming frontend URLs to the right Drupal entity; solves routing, not URL serialization. |
Full documentation is available in the README file, covering:
Initial development by SystemSeed. Ongoing maintenance sponsored by Finalist.