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
    value and in the computed processed
    output.
  • Views REST Export support – Works for both
    the Entity and Fields row plugins; rendered
    MarkupInterface values are rewritten before they reach
    the encoder.
  • Explicit base URL override – Set
    $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.
  • 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 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.

Documentation

Supporting organizations: 
Initial development
Sponsoring maintenance

Project information

Releases