5

We are trying to use display names for URLs and it doesn't work with JSS. E.g. we have a page "search" which has a display name in NL: zoeken.

  • when I request http://localhost:3000/en/search , the JSS api call is http://local.sc/sitecore/api/layout/render/jss?item=%2Fsearch&sc_lang=en (I've omitted api key), and it returns page data -> OK
  • when I request http://localhost:3000/nl/zoeken, the JSS api call is http://local.sc/sitecore/api/layout/render/jss?item=%2Fzoeken&sc_lang=nl, and it returns 404 -> NOK

We use Sitecore 9.1 initial release. Looks like a bug, but can I maybe there's a workaround? Thanks in advance!

UPDATE Actually, the problem happens not only in connected mode but also in integrated.

E.g. if I request http://local.sc/nl/zoeken - the page will be rendered, because in that case Item resolution pipeline runs and sets item correctly based on the display name.

However, if I request http://local.sc/en/search and then using the language switcher will try to navigate to /nl/zoeken, this will fail, because React router takes over the navigation and instead of requesting the whole page from the server, it only tries to retrieve /sitecore/api/layout/render/jss?item=%2Fzoeken&sc_lang=nl which return 404.

Concluding the above, I think this is a bug in Sitecore, particularly in the item resolution pipeline of the Layout Service.

4
  • first thing I would test if everything is published
    – Tony
    Oct 9, 2019 at 18:53
  • and also check if there is a version for the "zoeken" page created in that language
    – Abhay Dhar
    Oct 10, 2019 at 5:25
  • @Tony: I work on the local site, it only uses master db, so publishing is out of equation ;)
    – mcsdwarken
    Oct 10, 2019 at 10:37
  • @AbhayDhar: yes, there's a version
    – mcsdwarken
    Oct 10, 2019 at 10:38

1 Answer 1

3

This is indeed a bug in pre-9.2 versions of Sitecore JSS. So you have 3 options:

  • Upgrade to 9.2 and use newer JSS version which has this bug fixed
  • Ask Sitecore Support to provide a fix for your version of Sitecore
  • As a do-it-yourself workaround, compare the implementation of the Sitecore.LayoutService.Mvc.ItemResolving.ItemResolver class from 9.2 version of JSS with the one from your version of Sitecore and implement a custom resolver based on the differences. After that you can replace the default implementation with your custom one in Sitecore DI configuration code:

    serviceCollection.Remove(ServiceDescriptor.Transient<IItemResolver, ItemResolver>()); serviceCollection.AddTransient<IItemResolver, YourFixedResolver>();

Your Answer

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

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