3

Getting the below error when browsing the app URL in connected mode:

enter image description here

On browsing https://xyz-app.dev.local it gets redirected to https://xyz-app.dev.local/sitecore/service/notfound.aspx

I can see the JSON response for it on https://xyz-app.dev.local/sitecore/api/layout/render/jss?item=/&sc_apikey={ABC}&sc_site=xyz-app

I can also see the content on http://localhost:3000/ and experience editor.

Sitecore version - 10.3

JSS version - 21.0.2

Framework - NextJs

xyz-app.config:

<sites>
    <site patch:before="site[@name='website']" 
    inherits="website" 
    name="xyz-app" 
    hostName="xyz-app.dev.local" 
    rootPath="/sitecore/content/xyz-app" 
    startItem="/home" 
    database="master" />
</sites>

<app name="xyz-app" 
    layoutServiceConfiguration="default" 
    sitecorePath="/sitecore/content/xyz-app" 
    useLanguageSpecificLayout="true" 
    graphQLEndpoint="/sitecore/api/graph/edge" 
    inherits="defaults" 
    serverSideRenderingEngine="http"
    serverSideRenderingEngineEndpointUrl="http://localhost:3000/api/editing/render"
    serverSideRenderingEngineApplicationUrl="http://localhost:3000" />
</apps>

scjssconfig.json:

{
      "sitecore": {
        "instancePath": "C:\\inetpub\\wwwroot\\sitecore103.dev.local",
        "apiKey": "ABC",
        "deploySecret": "abc",
        "deployUrl": "https://xyz-app.dev.local/sitecore/api/jss/import",
        "layoutServiceHost": "https://xyz-app.dev.local"
      }
}

I've allowed all (*) for CORS origin and allowed controls on the API key.

4
  • It looks like xyz-app.dev.local is your Sitecore instance. Your headless site should have its own url. Its not hosted on the Sitecore instance
    – Richard Seal
    Commented Jan 3, 2023 at 15:47
  • @RichardSeal I created another app and passed the app URLs (modified the post to reflect the URLs) but I still get redirected to notFound.aspx. Ps, I can browse the app on localhost:3000 and experience editor.
    – Anonymous
    Commented Jan 4, 2023 at 9:50
  • @Anonymous Did you find any solution to this issue ?
    – Dheeraj p
    Commented Apr 5, 2023 at 10:44
  • In the app registration try adding: serverSideRenderingEngineEditOnly="false"
    – Jamien
    Commented Jun 6, 2023 at 3:45

3 Answers 3

3

In xyz-app.config add the following to the app registration section (doesn't matter where in the list of values):

<app name="xyz-app"...    
...   
serverSideRenderingEngineEditOnly="false" />

Default value for this is true, which seems to disable the rendering engine from loading outside Experience Editor.

In our environment we had the same issue as OP, setting the value in the app registration section of the config allowed the page to load again as expected - Worth noting though that it's still offloading the rendering to the rendering host, so it's just extra hops compared to going to the rendering host URL directly.

2
  • can you explain why this would help OP with their issue?
    – Marek Musielak
    Commented Jun 6, 2023 at 11:23
  • Default value for this is true, which seems to disable the rendering engine from loading outside Experience Editor. In our environment we had the same issue as OP, setting the value in the app registration section of the config allowed the page to load again as expected - Worth noting though that it's still offloading the rendering to the rendering host, so it's just extra hops compared to going to the rendering host URL directly.
    – Jamien
    Commented Jun 7, 2023 at 3:32
0

Yes, It will give you the not found page but why you are trying to open this?

You are using headless service/JSS and you must have created site in your sitecore instance which will serve the content through Layout service to your front end application created in next.js( http://localhost:3000/ in your case on local) and that is the fundamental use case of sitecore headless, so it won't open it though the CD url (There is no use of it).

The reason why you are able to open it in experience editor because you would have provided rendering host details in one of the item inside /sitecore/system/Settings/Services/Rendering Hosts/Default if you are using Headless Sxa

Connecting a Next.js JSS app to Sitecore editors

enter image description here

Or added code through patch file if not using Headless Sxa

 <javaScriptServices>
          <apps>
            <app name="exampleApp"
                ...
                serverSideRenderingEngine="http"
                serverSideRenderingEngineEndpointUrl="http://localhost:3000/api/editing/render"
                serverSideRenderingEngineApplicationUrl="http://localhost:3000"
                ...
            />
          </apps>
   </javaScriptServices>
0

If you are using SXA and your JSS app resides within an existing Sitecore site, you don't need site definitions in your configuration; you can comment out those lines.

Create a Site Grouping Item for Content Management (CM) and include necessary details such as site name, validity for environment, target hostname, etc.

Include the Sitecore instance URL in the target hostname field.

Now, you can load your site in connected mode, where your JS app is inside the Sitecore dist folder.

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.