Closed rasheedhere-architech closed 4 years ago
hi @rasheedherel1 that is the expected output of the node server (4200). Assuming you have updated the page component HTL and configured the GetPreRenderedPageBody service in AEM, you should now be able to navigate to AEM localhost:4502/path/to/page and see the SSR in action
hi @rasheedherel1 that is the expected output of the node server (4200). Assuming you have updated the page component HTL and configured the GetPreRenderedPageBody service in AEM, you should now be able to navigate to AEM localhost:4502/path/to/page and see the SSR in action
Hi @godanny86, thanks for the quick response. I see that page is being rendered server side, but I see we are still making the js calls even though it is not required. Is there any way we can avoid these unnecessary js calls from the script tags on client side. Cheers!
hi @rasheedherel1 if set up correctly you should not see any XHR calls to .model.json
on the initial page load. Are you still seeing those requests?
@godanny86 You are right, I don't see .model.json
calls when in SSR. But I still see .js
(client-libs, main, we-retail-journal-react-app) calls on page load, which I shouldn't see if the page is being rendered server side.
If I disable javascript in the browser then I don't see any .js
and .model.json
calls as well.
But I see page being server side rendered in all cases. Just that we are unnecessarily making .js
calls when SSR.
Any insight on why the behaviour is like this?
hi @rasheedherel1 the goal of SSR is simply to accelerate the initial page load, so that content is visible before the .js and avoid the extra .model.json request. It is expected to eventually load the JS and have it take control of the app.
Ok thanks! @godanny86
will close for now, feel free to open if you have other questions!
Thanks! @godanny86
Hi guys,
I tried to implement Server side rendering the React SPA in our project by following the documentation as mentioned below but didn't find it is working.
I was able to start the nodejs server fine on 4200 and configured the path in servlet config as well.
But I tried to hit the localhost:4200/path/to/page, I am getting back response like,
Can someone please advice if I am missing something here,
Here is the documentation I followed,
npm run build
API_HOST=http://localhost:4502 npm run start:server
../content/jcr_root/apps/we-retail-journal/react/components/structure/page/body.html
API_HOST=http://localhost:4502 APP_ROOT_PATH=/content/we-retail-journal/react npm run start:server