0

我已经使用 Hybris 1905、npm、node 和 angularcli 建立了我的 spartacus 商店。但是在点击主页 url localhost:4200 时,我得到一个空白页面。请帮忙

4

4 回答 4

1

我使用(最新的)Angular CLI 8.3.25、Node 12.16.1、Yarn 1.22.0 测试了 Spartacus 1.4 Electronics SPA,它运行良好。

正如其他人提到的,这可能是一个 CORS 问题。如果 CORS 配置不正确,我也会得到一个空白页,但如果我添加 CORS 配置,我会工作。尝试将其添加到您的local.propperties并重新启动 Hybris 应用程序:

corsfilter.ycommercewebservices.allowedOrigins=http://localhost:4200 https://localhost:4200
corsfilter.ycommercewebservices.allowedMethods=GET HEAD OPTIONS PATCH PUT POST DELETE
corsfilter.ycommercewebservices.allowedHeaders=origin content-type accept authorization cache-control if-none-match x-anonymous-consents
corsfilter.ycommercewebservices.exposedHeaders=x-anonymous-consents
corsfilter.assistedservicewebservices.allowedHeaders=origin content-type accept authorization x-anonymous-consents
corsfilter.assistedservicewebservices.exposedHeaders=x-anonymous-consents

注意:Spartacus 文档推荐 Angular 8.x,而不是 9.x。

于 2020-03-05T04:53:19.120 回答
1

这听起来像是 Hybris 中不存在 Sampledata 或者存在 CORS 问题,您是否在 Hybris 中安装了 Samplestore 并配置了 CORS?

以下是 Spartacus 文档的链接:

https://sap.github.io/cloud-commerce-spartacus-storefront-docs/installing-sap-commerce-cloud/#setting-up-sap-commerce-cloud

https://sap.github.io/cloud-commerce-spartacus-storefront-docs/installing-sap-commerce-cloud/#configuring-cors

于 2020-02-28T05:36:09.007 回答
0

问题已解决。这是因为我们使用了最新版本的 node 和 angular cli。

于 2020-03-02T15:53:24.840 回答
0

你确定你在http://localhost:4002上运行应用程序吗?

angular CLI 默认使用4200端口。如果您确实指的是 4200 端口,也许您可​​以从浏览器控制台共享任何日志?可能会有一些有用的消息表明该问题。

于 2020-02-27T09:00:23.947 回答