小编kas*_*unb的帖子

如何使用代理配置将 angular 2 应用程序部署到 HTTP 服务器

我正在使用以下代理配置构建 angular 2 应用程序。

代理配置文件

{ 
 "/": {
  "target": "http://localhost:6060",
  "secure": false,
  "changeOrigin": true,
  "logLevel": "debug" 
}}
Run Code Online (Sandbox Code Playgroud)

我使用 spring boot 应用程序作为我的后端,它在端口 6060 上运行

我的包json的构建脚本如下

包.json

"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
Run Code Online (Sandbox Code Playgroud)

当我使用npm start 时,应用程序工作正常。所有后端请求都发送到http://localhost:6060

然后我使用构建生产版本

ng build --prod --proxy-config proxy.conf.json
Run Code Online (Sandbox Code Playgroud)

并将生成的代码部署到 HTTP 服务器(apache 服务器)。然后我访问http://localhost/应用程序统计信息。但是当我尝试发出请求时,这些请求指向http://localhost/ ...而不是http://localhost:6060

我试图找到一些解决方案,但没有这些解决方案。请给我一些帮助。

谢谢

deployment angular angular5

5
推荐指数
1
解决办法
4911
查看次数

标签 统计

angular ×1

angular5 ×1

deployment ×1