Since JSON:API is often used in headless setups, the frontend domain might be different from the Drupal backend. For security reasons, we want to hide the URL of the Drupal system and only provide relative URLs in all JSON:API resources (which are then accessed through a proxy).
For our setup we wrote the attached simple patch, which makes use of the FileUrlGenerator to turn the image URLs into relative ones.
I know, this module was written with simplicity in mind, thus the question if an admin option for this module would be a feature you'd support? We could then extend the patch in such a way.
It's totally okay if not, in that case, the attached patch may help others.
Active
3.0
Code