angular / angular/angular-cli

ng serve with traditional backend

Aperta
#24,478 5 commenti 5 reazioni 0 assegnatari Vedi su GitHub
angular/build:dev-server area: @angular/build feature feature: insufficient votes
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

### 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.
![image](https://user-images.githubusercontent.com/46120703/210085539-caec948c-1db4-4912-8fbd-1cf0190798bd.png)

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia tracciando la gestione di ng serve per /ng-cli-ws, degli asset caricati lazy, dei file hot-update e del comportamento di options.ssl, quindi esamina il flusso public-host esistente. Il lavoro è completo quando esiste un modo supportato per servire gli asset di sviluppo di Angular e websocket tramite un backend tradizionale senza compromettere il routing del backend o la selezione del protocollo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
cli
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.