2

My Sitecore CD website in IIS is http://cd.my-website.com with a role as ContentDelivery. This site contains Sitecore and custom API code in Headless mode.

The React code for the JSS app is on a different website http://fe.my-website.com (No Sitecore). JSS App is connecting to the http://cd.my-website.com through Layout ServiceHost.

All sites are separate in IIS and also separate folders pointing to the same database on a local machine.

The sites are working fine except personalization. We have set some personalization based on custom rule and some OOB rules.

The personalization is not working when I access the site using the http://fe.my-website.com.

I checked very weird behavior for the below URL

http://cd.my-website.com/sitecore/api/layout/render/jss?item=%2Fenterprise&sc_lang=en&sc_apikey={ourAPIKey}

When it is accessed through the FE website, the Layout service is called as an Ajax request and it can be found in XHR under network in the developer toolbar. The site is not showing any personalization when called in this way. Even I set some very basic OOB Sitecore personalization like date or day or month.

In XHR, I can find the call to the layout service. When I checked the response, I didn't find any personalized content. When I opened the same URL in the browser (right-click and open in new tab), I can see all personalization applied correctly. The output is different than the Ajax request.

When I deployed the React code in Sitecore site under /dist/myproject/ and tried to access personalization worked fine (Integrated mode).

Edit 1:

Sitecore 9.1 initial release

License: xDB enabled

xDB settings: Default/No Change

2
  • Can you check if IIS sets any kind of caching settings on the Node.js app
    – Anastasiya
    Sep 10, 2020 at 18:08
  • Also make sure you are including cookie information when you call the cd LayoutService from your front-end site. The fetch() function doesn't do this by default.
    – Anastasiya
    Sep 24, 2020 at 14:39

1 Answer 1

0

It's likely that the issue lies in the passing of the personalization context during Ajax requests from the JSS app to the Layout Service. To address this, it's important to thoroughly examine how your React app is making calls to the layout service and vice versa.

Check the implementation in your React app to ensure that any relevant user or session information required for personalization is being properly included in the Ajax requests. Additionally, review the configuration and handling of personalization context within the Layout Service to ensure it correctly interprets and applies the received information.

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.