1

We are running Next.js JSS app using XM Cloud docker setup, our localhost:3000 site is loading, but when we are trying to run Experience Editor it is giving 2 erros.

On First Try we are getting below error:

A Sitecore.JavaScriptServices application was not found for the path {itempath}. You should ensure that:
* You have applied a Sitecore configuration patch for the application (see App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.ExampleApp.config.example)
> * The path represents a Route
* The Route item is a descendant of an App item

If I change the URL with query string sc_site to sc_jssapp it is giving us below error

2836 06:24:55 ERROR [JSS] Error occurred during POST to remote rendering host: `http://localhost:3000/api/editing/render`
2836 06:24:55 ERROR Unable to connect to the remote server
Exception: System.Net.WebException
Message: Unable to connect to the remote server
Source: System
   at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
   at System.Net.WebClient.UploadString(Uri address, String method, String data)
   at Sitecore.JavaScriptServices.ViewEngine.Http.RenderEngine.Invoke[T](String moduleName, String functionName, Object[] functionArgs)

Nested Exception

Exception: System.Net.Sockets.SocketException
Message: No connection could be made because the target machine actively refused it 127.0.0.1:3000
Source: System
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

We have already checked JSS_Editing Secret in .env file and Sitecore config.

1 Answer 1

1

You make request from Sitecore container. localhost on the Sitecore container is not equal to localhost on your local machine.

enter image description here

Localhost inside container is this container address. You can't request from the Docker container your sites that are hosted on your machine. What you can do: setup rendering host container inside your Docker network and change http://localhost:3000/api/editing/render to the address of your rendering host container, e.g. http://localhost:3000/api/editing/render

5
  • 1
    Thanks I am able to resolve both the issues by changing localhost:300 to rendering:3000 and also sc_site querystring param is also working fine by changing app item template and home item template to route template in jss Commented Mar 10, 2023 at 3:01
  • One caveat to this diagram is that you actually can access your machine localhost from containers network, it just has to be with the host host.docker.internal Commented Jan 30 at 21:41
  • @BenSewards Yes, for a major part of containers. But it doesn't work for CM container out of the box! You need to do a little trick to achieve it: exdst.com/posts/…
    – Anton
    Commented Feb 2 at 10:13
  • That's informative, I can confirm that I cannot ping it within my local CM on v4.22.1 still, but the node rendering host works. Commented Feb 2 at 20:35
  • 1
    @BenSewards Yes, it should be the default behavior for all containers according the Docker documentation. But for some reason, it doesn't. And I didn't find the root, of why some containers have this issue host.docker.internal. The easy way was to path hosts file
    – Anton
    Commented Feb 3 at 20:07

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.