我在Azure Web应用程序中托管了两个单独的Web应用程序。
一个基于angular js 8前端,另一个基于.net核心Web API 2.2。
我已经创建了一个基本方法来从Web API调用返回value1和value 2的值,类似的还有一些其他API方法可以返回json。
如果我在浏览器https://B.azurewebsites.net/api/values中调用,则成功返回了value1和value 2。
现在我的前端有角度的Web应用程序正试图在运行http://localhost:4200的本地计算机中调用Web api,并调用如下所示的Azure托管Web api
export class ApiDataService
{
private REST_API_SERVER = ""; //mentioned in constant file under services
constructor(private httpClient: HttpClient) {
this.REST_API_SERVER = "https://B.azurewebsites.net/api";
}
public getList() {
return this.httpClient.get(this.REST_API_SERVER +
"/employee/getlist").pipe(catchError(this.handleError));
}
在本地计算机上,它运行良好。
在Azure中部署有角度的Web应用程序时,它会显示错误404和消息:
#
http:https://A.azurewebsites.net/B.azurewebsites.net/api/employee/getlist的失败响应
#
在这里A.azurewebsites.net-> Angular Web应用程序
B.azurewebsites.net-> .Net Core Web API 2.2
我无法找到azure网站两次调用的任何原因 它应该简单地称为https://B.azurewebsites.net/api/employee/getlist
我还从
之类的有角项目中的index.html中删除了“ /”<base href=""/> --removed the "/"
如何在employee.component.ts中重置基本URL
任何建议或评论将非常有帮助。