I have created separate bindings for the basic and advanced sample JSS apps as outlined in

https://jss.sitecore.net/#/setup/sitecore-config?id=sitecore-configuration 
  • 127.0.0.1 JssBasicApp
  • 127.0.0.1 JssAdvancedApp

This works fine. When I click through the advanced app, I can see calls to the layoutservice like:

http://jssadvancedapp/sitecore/api/layout/render/jss?item=/portfolio&sc_lang=en&sc_apikey={KEY}

However, when I don't use separate IIS bindings, but instead configure subsites for JssBasicApp and JssAdvancedApp, the layoutservice calls get problematic. When I click through the advanced sample app, in the network tab in my browser I see calls like:

http://jss-sc.com/jssadvancedapp/sitecore/api/layout/render/jss?item=/jssadvancedapp/portfolio&sc_lang=en&sc_apikey={KEY}

resulting in a 404 not found error:

http://jss-sc.com/sitecore/service/notfound.aspx?item=/sitecore/api/layout/render/jss&user=sitecore\admin&site=jssadvancedapp

Obviously, the Sitecore layoutservice is not called here, but Sitecore is trying to find the item /sitecore/api/layout/render/jss under the JssAdvanced node.

The following call gives a 404 error (removed the jssadvancedapp section after hostname):

http://jss-sc.com/sitecore/api/layout/render/jss?item=/jssadvancedapp/portfolio&sc_lang=en&sc_apikey={KEY}

Adding &site=jssadvancedapp to the url gives the same 404 error.

So the question is, what is the right api call? And how to set the configuration so that the right api call is made instead of the above wrong one.

This is how the sites configuration looks like:

<sites>
<site name="shell" virtualFolder="/sitecore/shell" physicalFolder="/sitecore/shell" rootPath="/sitecore/content" startItem="/home" language="en" contentLanguage="en" database="core" domain="sitecore" loginPage="/sitecore/login" content="master" contentStartItem="/Home" enableWorkflow="true" enableTracking="false" analyticsDefinitions="content" xmlControlPage="/sitecore/shell/default.aspx" browserTitle="Sitecore" htmlCacheSize="10MB" registryCacheSize="15MB" viewStateCacheSize="1MB" xslCacheSize="25MB" disableBrowserCaching="true" enableItemLanguageFallback="false" enableFieldLanguageFallback="false" itemwebapi.mode="StandardSecurity" itemwebapi.access="ReadWrite" itemwebapi.allowanonymousaccess="false" patch:source="Sitecore.Speak.ItemWebApi.config"/>
<site name="login" virtualFolder="/sitecore/login" physicalFolder="/sitecore/login" enableTracking="false" database="core" domain="sitecore" disableXmlControls="true" language="en"/>
<site name="admin" virtualFolder="/sitecore/admin" physicalFolder="/sitecore/admin" enableTracking="false" enableWorkflow="true" domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>
<site name="service" enableTracking="true" virtualFolder="/sitecore/service" physicalFolder="/sitecore/service"/>
<site name="modules_shell" virtualFolder="/sitecore modules/shell" physicalFolder="/sitecore modules/shell" rootPath="/sitecore/content" startItem="/home" language="en" database="core" domain="sitecore" content="master" enableTracking="false" enableWorkflow="true"/>
<site name="modules_website" virtualFolder="/sitecore modules/web" physicalFolder="/sitecore modules/web" rootPath="/sitecore/content" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true"/>
<site name="jssadvancedapp" inherits="website" virtualFolder="/jssadvancedapp" physicalFolder="/jssadvancedapp" rootPath="/sitecore/content/jssadvancedapp" startItem="/home" database="master" patch:source="jss-advanced-app.config"/>
<site name="jssbasicapp" inherits="website" virtualFolder="/jssbasicapp" physicalFolder="/jssbasicapp" rootPath="/sitecore/content/jssbasicapp" startItem="/home" database="master" patch:source="jss-basic-app.config"/>
<site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" enableItemLanguageFallback="false" enableFieldLanguageFallback="false" itemwebapi.mode="Off" itemwebapi.access="ReadOnly" itemwebapi.allowanonymousaccess="false" patch:source="Sitecore.ItemWebApi.config"/>
<site name="scheduler" enableTracking="false" domain="sitecore"/>
<site name="system" enableTracking="false" domain="sitecore"/>
<site name="publisher" domain="sitecore" enableTracking="false" enableWorkflow="true"/>
<site name="exm" inherits="shell" virtualFolder="/" physicalFolder="/" startItem="/none" cacheHtml="true" htmlCacheSize="50MB" patch:source="Sitecore.EmailExperience.Core.config"/>

  • Great question. In order to sort it out, would you be able to paste in your sites configuration? The <sites /> section from /sitecore/admin/showconfig.aspx – Alex Shyba Feb 6 at 18:46
  • Pasted in the <sites> configuration – staccata Feb 6 at 19:15
  • Thanks! I don't think you are missing anything obvious here as I am seeing the same on my end. Need to debug it a bit. Gut feeling is that the site resolver based on virtualFolder and physicalFolder doesn't work well with SSC. Please stay tuned! – Alex Shyba Feb 6 at 19:35
up vote 3 down vote accepted

Could you please try the following solution?

  1. Add the following after line 10 in advanced-sample-react\src\dataProvider\DataProvider.prod.js: params.sc_site = 'jssadvancedapp';

    For context: const getFetchOptions = (language, options = {}) => { const params = options.params || {}; params.sc_site = 'jssadvancedapp'; ...

    this forces the site context switch via query string. The value will vary per JSS app naturally.

  2. Drop this DLL into the /bin (make a copy of your current Sitecore.LayoutService.Mvc.dll prior to that)

Please let us know if this fixes the issue so we can put the official fix out for the next update.

  • ok, I'll check it out and will let you know. – staccata Feb 8 at 12:42
  • This works! I see now that in the api call the sc_site parameter is added: &sc_site=jssadvancedapp and the api now returns the expected json. Thanks for the quick fix. – staccata Feb 12 at 9:33
  • Awesome, thanks for confirming the fix. This will be addressed in JSS Tech Preview Update-2. – Alex Shyba Feb 13 at 19:11
  • This is now fixed in Preview 2. Adding “sc_site” Parag is still needed but the server now behaves properly ;-) – Alex Shyba Mar 3 at 19:39

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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