我只是使用AngularUniversal“扩展”了我的项目,它几乎可以正常工作,唯一对我不起作用的是获取api数据。 当我在浏览器中运行时,一切正常,所有api调用均正常,但ssr端无法正常工作,我收到此错误:
Trace: [Error]
at ZoneDelegate.invoke (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:551:26)
at Zone.run (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:301:43)
at Console.console.(anonymous function) [as trace] (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:2446:38)
at SafeSubscriber._error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:85065:25)
at SafeSubscriber.__tryOrUnsub (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27929:16)
at SafeSubscriber.error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27880:26)
at Subscriber._error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27813:26)
at Subscriber.error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27793:18)
at MapSubscriber.Subscriber._error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27813:26)
at MapSubscriber.Subscriber.error (/Library/WebServer/Documents/gitprojects/shop/dist/app.js:27793:18)
我的应用程序的一部分未在服务器上呈现。
我正在使用完整路径,例如http://api.local.pl/api/data。 我使用的是最新的angular 7版本,所有内容都是最新的(也许那是我的问题?)
从APP_INITIALIZER类调用的简单Observable返回错误(因此在应用渲染之前)
this.sub = this.navigationService.settings('en-US').subscribe(
setup => {
//some code
},
error => {
console.trace(error); <- my error
}
);