加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在Angular.io中配置HTTP的端口

发布时间:2020-12-17 06:49:03 所属栏目:安全 来源:网络整理
导读:我想创建一个angular.io应用程序,但其余的API应从不同的服务器端口提供. 来自localhost:4200的Angular内容,来自node express服务器的数据在localhost:3000上独立启动. 但是当我注入并使用’http’时,如何配置要使用的端口? 解决方法 以某种方式获得“正确
我想创建一个angular.io应用程序,但其余的API应从不同的服务器端口提供.

来自localhost:4200的Angular内容,来自node express服务器的数据在localhost:3000上独立启动.
但是当我注入并使用’http’时,如何配置要使用的端口?

解决方法

以某种方式获得“正确”URL的解决方案无效.
事实证明,这导致了一种情况,其中在休息服务器上看到http.put(…)作为OPTIONS请求.

Angular $http is sending OPTIONS instead of PUT/POST

通过从角度服务器代理到其余服务器,我找到了一种工作方式:

angular-cli server – how to proxy API requests to another server?

ng serve --proxy-config proxy.conf.json

proxy.conf.json:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读