且构网

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

如何在同一主机上运行Angular 2客户端应用程序和节点服务器应用程序

更新时间:2022-01-15 07:15:19

假设您的快速站点在localhost:3500上运行,并且所有api调用均以/api

Suppose your express site is running on localhost:3500 and all api call begins with /api

使用内容创建proxy.conf.json

create proxy.conf.json with the content

{
  "/api": {
    "target": "http://localhost:3500",
    "secure": false
  }
}

然后编辑package.json并将"start": "ng serve",更改为"start": "ng serve --proxy-config proxy.conf.json"

现在使用命令npm start运行项目.注意:- ng服务将不起作用

now run the project using command npm start.Note:- ng serve will not work

有关更多信息,请找到文档化在这里

For more information find documatation here