This module ensures that file and image URLs within your content are absolute, not relative. This is essential for headless setups where your frontend framework needs full URLs to correctly display images and other assets from your Drupal site. It automatically converts relative internal URLs to absolute ones, pointing them to the correct server where the files are hosted.
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.
Features
- Zero-config by default – Enable the module
and relative URLs in formatted text fields become absolute in your
JSON:API and REST responses. - Covers CKEditor content – Rewrites
<img src>and<a href>inside
body fields and other formatted-text fields, both in the raw
valueand in the computedprocessed
output. - Views REST Export support – Works for both
the Entity and Fields row plugins; rendered
MarkupInterfacevalues are rewritten before they reach
the encoder. - Explicit base URL override – Set
$config['rest_absolute_urls']['base_url']in
settings.phpfor Docker, Kubernetes, server-side
rendering or any setup where Drupal cannot detect the public host
reliably. - Per-environment configuration – Switch
base URLs between production, staging and local environments with
standard PHP settings logic. - Safe for non-text fields – Only rewrites
properties that are declared as the source of a processed text, so
plain string fields are not touched and never double-encoded. - No external dependencies – Requires only
the core Serialization module.
Why use this module?
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.
Comparison with related modules
Module Approach Best for REST Absolute URLs Serializer-level normalizers rewrite embedded URLs informatted 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.
Ask your assistant about REST absolute URLs
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- serialization Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 2.1.1 | Stable | 11 | Oct 2, 2026 | ||
| 2.1.0 | Stable | 11 | Sep 25, 2026 | ||
| 2.0.1 | Stable | 10–11 | Sep 25, 2026 | ||
| 2.0.0 | Stable | 8–11 | Aug 30, 2024 | ||
| 8.x-1.0-beta3 | Pre-release | 8–10 | Feb 23, 2024 |