有个使用SAP Spartacus的客户遇到一个问题:这个问题乍一看有点奇怪,当浏览器缩放比率为90%时,checkout-login 页面可以正常工作,但是当缩放率调至100%时,反而不能正常工作了,会显示not-found页面。
原因分析
we found an error in “CustomOccCmsPageNormalizer” at:
问题是下面这段客户自开发代码引起的:It seems like “supportComponentData” is undefined in some case. This variable contains the “MySupportComponent” component from the response. Since “supportComponentData” is undefined an error is thrown which causes the “checkout-login” page rendering to fail. Spartacus then falls back to getting the “not found” page.
To explain further, in the “CmsPageGuard”, Spartacus calls “CmsService.getPage” which will try to load the checkout page.
Since there is an error in the page normalizer, the “CmsService” will return “false” to the “CmsPageGuard” meaning the page wasn’t rendered. The “CmsPageGuard” then goes ahead and requests the “not found” page.
Because of an “if statement” wrapping the failing logic, the problem is only visible for screen sizes between 768 and 1399 (inclusively).
这个问题只有在屏幕尺寸位于区间768~1399区域内才能重现。
Additionally, we were not able to witness this same problem on the d1 server which might mean that the p1 server is missing the “MySupportComponent”.