1

I have setup Sitecore JSS project from Getting Started template and I am using XP1 topology with CD and CM on separate containers to simulate actual production environment. However my problem is the images or media returns in HTTP instead of HTTPS, that will cause the images unable to load.

enter image description here

Below are the source returns:

enter image description here

It is working on CM and Experience Editor but it does not work when I publish and view from CD.

Snippet from rendering server, I print out the content of the fields:

enter image description here

2
  • Welcome to SSE, Faizal. Since you are using JSS, your website is served from rendering host container. May I know why are you using CD instance here ? Nov 24, 2023 at 17:02
  • Hi Vikrant. I am new with JSS/Sitecore and I use XP1 for my docker compose setup. I'm using ImageField to retrieve the Image from Sitecore and it translated to the URL from CD as above. Is this not a correct approach? <NextImage field={props.fields.image.value} height="50" width="200" /> Nov 28, 2023 at 6:24

1 Answer 1

2

Try to set the IncludeServerUrlInMediaUrls to false for the layoutservice you are using - something like this:

<layoutService>
  <configurations>
    <config name="default">
        <rendering>
            <renderingContentsResolver>
                <IncludeServerUrlInMediaUrls>false</IncludeServerUrlInMediaUrls>
            </renderingContentsResolver>
      </rendering>
    </config>
    <config name="jss">
      <rendering>
        <renderingContentsResolver>
          <IncludeServerUrlInMediaUrls>false</IncludeServerUrlInMediaUrls>
        </renderingContentsResolver>
      </rendering>
    </config>
    <config name="sxa-jss">
      <rendering>
        <renderingContentsResolver>
          <IncludeServerUrlInMediaUrls>false</IncludeServerUrlInMediaUrls>
        </renderingContentsResolver>
      </rendering>
     </config>
  </configurations>
</layoutService>

This way you should get relative urls in the graphql output.

3
  • it works! Thank you Nov 28, 2023 at 15:42
  • No problem - don't forget to mark the answer as accepted ;)
    – Gatogordo
    Nov 29, 2023 at 7:48
  • The answer works, however got a few comments: 1. For XM Cloud you need to set false only config name="sxa-jss", there was no mention to it in the documentation, so I tried the above patch but for other onfig - JSS which obviously did not work. "sxa-jss" is the one that is in use; 2. Still wondering why protocol generates as HTTP rather than HTTPS, when not using relative path Dec 1, 2023 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.