且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular2 http.get(url)正在返回404的有效网址 - 而不是CORS问题

更新时间:2023-11-19 18:14:28

我能够在另一个堆栈溢出问题中找到一个工作修复:

I was able to find a working fix in another stack overflow question:

角度2 HTTP GET返回URL null

问题是使用InMemoryWebApiModule,解决方案是对我的app.module.ts文件进行以下配置修改:

The problem was with the InMemoryWebApiModule and the solution was to make the following config modification to my app.module.ts file:

- InMemoryWebApiModule.forRoot(InMemoryDataService),
+ InMemoryWebApiModule.forRoot(InMemoryDataService, {passThruUnknownUrl: true}),

使这个小的配置更改导致应用程序工作。

Making this small config change caused the application to work.