Setting Up a Next.js Coupled Solution with a Node.js Proxy on Optimizely 12 DXP

Vote:
 

We are starting an Optimizely 12 CMS multilingual website build. We plan to render Optimizely content with a NextJS with server-side rendering, client-side routing, working On-Page Edit (OPE) mode, and where the client app and backend are hosted in the same application. The client app is hosted in its own Noje.js process and then proxied by dotnet , Similar to the approach here - https://github.com/johantor/content-delivery-js-sdk/tree/music-festival-react-coupled/samples/music-festival-vue-coupled

In startup.cs a proxy is added by calling services.AddNodeJs() and by calling app.UseEndpoints(e => e.MapNodeJs()); a fallback endpoint is registered to the Node.js process. This means if an incoming request doesn't match any other endpoint, for example, a controller, the request will be proxied to the Node.js process. 



My Artifact Structure looks like this 



/wwwroot contains the nextjs App build output 

DXPplatform settings file 


The nodeJS proxy seems to work all right on my local machine with npm run dev 

However, The artifact deployed to DXP environment seems to throw a 500 
 
Startup.cs 



I’m new to Optimizely development, and I’d greatly appreciate any guidance on configuring this NodeJS proxy for Optimizely 12 DXP (Linux).



#325539
Edited, Jul 17, 2024 17:28
Vote:
 

Optimizely is deployed into a Docker Container, on the Linux WebApp so their may be some configurations once deployed which are not like for like to your local setup. 

Their is this blog post where Dave has utilised YARP (Yet another reverse Proxy) with CMS 12, is this something you could also leverage ? 

https://buildoptimizely.com/episerver/optimizely-cms-12-implementing-a-reverse-proxy-with-yarp/ 

#325764
Jul 22, 2024 8:56
Vote:
 

Thanks for your response Minesh, 

The problem seems to be with the web app (Linux Container) not responding to requests and timing out. There are no errors on the logs 

I am trying to browse Integration from - https://webappnameinte.dxcloud.episerver.net/

should I be aware of any specific ports configuration while deploying to a Linux container ? 

my start up class look something like this 



build and publish 








#325771
Edited, Jul 22, 2024 11:49
Vote:
 


The issue seems like the primary dotnet process can be accessed from localhost because it’s directly linked to the host, which is a Linux machine. However, the inner process (nodeJS) resides inside a container, and the container’s IP address  will be used for all sub-processes of dotnet.

 

#325904
Edited, Jul 23, 2024 10:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.