SAP Spartacus 服务器端渲染返回的源代码不全的问题及解决方案

120 阅读1分钟

如下图所示:

我本地启用SSR后,服务器端返回渲染好的源代码里,每个cx-page-layout标签都是空的:

但是用来做SSR测试的服务器上,返回的是完整的源代码:

原因:

Additionally, it looks like you might have an invalid certificate on the back-end, which causes the angular SSR render to pass (therefore you see the regular non-CMS angular components being rendered), but you won’t see Spartacus’ CMS components being rendered.To go around this in development, you can first install “cross-env” package, and then run “cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node dist/storefrontapp-server/main.js”.After doing all this, you should be able to see the more sensible response.

解决方案:

cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node dist/storefrontapp-server/main.js

更多Jerry的原创文章,尽在:“汪子熙”: