Skip to main content
edited tags
Link
Artem Prashkovich
  • 4.1k
  • 1
  • 17
  • 32

JSS site root item React client-side routingLayout Service fails an item resolving by path with virtual directory

I am using Sitecore 9.3 JSS with a Create React App front-end with a virtual folder setup.

When I create a link pointing to the site root item, it works fine when directly browsing to it e.g. opening http://localhost/virtualfolder/roothttp://localhost/virtualfolder/root.

But when I use client-side navigation (with React router under the hood) the page (/root) cannot be found.

This is due to Layoutservice HTTP call that does not return any route data for: http://localhost/sitecore/api/layout/render/jss?item=%2Froot&sc_apikey=&sc_site=my-apphttp://localhost/sitecore/api/layout/render/jss?item=%2Froot&sc_apikey=<key>&sc_site=my-app

When I manually change this to http://localhost/sitecore/api/layout/render/jss?item=/&sc_apikey=&sc_site=my-apphttp://localhost/sitecore/api/layout/render/jss?item=/&sc_apikey=<key>&sc_site=my-app it returns route data.

Any clues on how to fix this?

I am using Sitecore 9.3 JSS with a Create React App front-end with a virtual folder setup.

When I create a link pointing to the site root item, it works fine when directly browsing to it e.g. opening http://localhost/virtualfolder/root.

But when I use client-side navigation (with React router under the hood) the page (/root) cannot be found.

This is due to Layoutservice HTTP call that does not return any route data for: http://localhost/sitecore/api/layout/render/jss?item=%2Froot&sc_apikey=&sc_site=my-app

When I manually change this to http://localhost/sitecore/api/layout/render/jss?item=/&sc_apikey=&sc_site=my-app it returns route data.

Any clues how to fix this?

I am using Sitecore 9.3 JSS with a Create React App front-end with a virtual folder setup.

When I create a link pointing to the site root item, it works fine when directly browsing to it e.g. opening http://localhost/virtualfolder/root.

But when I use client-side navigation (with React router under the hood) the page (/root) cannot be found.

This is due to Layoutservice HTTP call that does not return any route data for: http://localhost/sitecore/api/layout/render/jss?item=%2Froot&sc_apikey=<key>&sc_site=my-app

When I manually change this to http://localhost/sitecore/api/layout/render/jss?item=/&sc_apikey=<key>&sc_site=my-app it returns route data.

Any clues on how to fix this?

Source Link
Joost
  • 1.9k
  • 1
  • 9
  • 26

JSS site root item React client-side routing fails

I am using Sitecore 9.3 JSS with a Create React App front-end with a virtual folder setup.

When I create a link pointing to the site root item, it works fine when directly browsing to it e.g. opening http://localhost/virtualfolder/root.

But when I use client-side navigation (with React router under the hood) the page (/root) cannot be found.

This is due to Layoutservice HTTP call that does not return any route data for: http://localhost/sitecore/api/layout/render/jss?item=%2Froot&sc_apikey=&sc_site=my-app

When I manually change this to http://localhost/sitecore/api/layout/render/jss?item=/&sc_apikey=&sc_site=my-app it returns route data.

Any clues how to fix this?