ng serve with traditional backend
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 14 小時 23 分鐘
- 30 天內合併 PR
- 162
描述
### Which @angular/* package(s) are relevant/related to the feature request?
compiler-cli
### Description
I would like to serve the index.html using a traditional backend, and use ng serve to get HMR for the angular app.
The issue with a proxy for the backend API calls is that development and production behave differently. Also, you cant have additional logic on the backend before serving the index.html (for example cookie auth)
### Proposed solution
Have a flag on `ng serve` that the websocket should go directly to the angular server. and would be nice if we can have a single script instead of having to add it all manually.
In vite all you need to do is add the following to your server's HTML template.
```
```
https://vitejs.dev/guide/backend-integration.html
### Alternatives considered
I tried adding the full path to the angular scripts, but the `/ng-cli-ws` calls goes to the backend server.
```
Angular
```
`--public-host=localhost:4200` fixes the /ng-cli-ws call, but lazy loading and the .hot-update.json still goes the backend server.

changing the base href to `https://localhost:4200/` fixes above, but breaks the routing links
also, you need to enable ssl if your backend is ssl, as it will go to wss instead of ws, i think this should rather be based on options.ssl see https://github.com/angular/angular-cli/issues/24373#issue-1475322626.
貢獻指南
研究方向
首先追蹤 ng serve 對 /ng-cli-ws、延遲載入的資產、hot-update 檔案以及 options.ssl 行為的處理,然後檢視現有的 public-host 流程。完成的標準是:提供一種受支援的方式,透過傳統後端提供 Angular 的開發資產和 websocket,同時不破壞後端路由或通訊協定選擇。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, typescript
- 領域
- cli
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100