Headless Server Developer Manual / Version 2204
Table Of ContentsFor this basic example, the original image is used. To use the address in an <img/>
tag, it needs to be absolute.
So the missing domain URL is combined with the string of the relative URI and written into the tag. In this example app
the URL is already used for configuring the Apollo Client and so it is a good approach to save it in an environmental
file to be accessed app wide. For example as REACT_APP_URL
:
const article = data.content.article; const serverUrl = process.env.REACT_APP_URL || ""; const imageUrl = serverUrl + article.picture.data.uri;
Example 14.12. Generating the full image URL