Dynamic base href (APP_BASE_HREF) for SSR
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- angular, typescript
Direzione di ricerca
Inizia leggendo AngularNodeAppEngine.handle e confronta la sua gestione di base-href con il comportamento esistente di CommonEngine e ngExpressEngine. Traccia il percorso con cui APP_BASE_HREF e la richiesta raggiungono il rendering SSR, quindi definisci cosa richiederebbe il supporto per un base href specifico per la richiesta. Il lavoro è completato quando l'output SSR può usare il base href fornito dalla richiesta senza analizzare manualmente il file index.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
I'm using Angular as SSR multi tenant app.
We differentiate the clients per domain.
exemple:
potato.com/portal
tomato.com/citizen
onion-tickets.com
The majority from our clients use a specific base href and just a few serve the app on the root.
Right now it's difficult to work with angular with this setup, I had to do some 'stuff' on the SSR server to make it work.
We use a similar configuration for development too because it's easy to use domains rather than keep changing the client for localhost. This also allows to have many clients configured at the same time.
For the development we simply add on the OS hosts file [CLIENT].local and have nginx running on docker.
This has sped up a lot of developing time.
We are migrating from angular 16 to 19 and already preparing for the AngularNodeAppEngine because from what I saw in the docs it will be the default instead of the ngExpressEngine and CommonEngine.
At the moment there are (what I believe is regression) some things that worked in v16 that don't work in v19, and it impacts production and development.
I was preparing a repo with an example app to list those problems, but later realized that if the APP_BASE_HREF doesn't work like before, none of the other stuff matters.
This is part of the code that we use to make it work.
// this will garantee that all the js are served from the right routes.
if (condition) {
res.render(indexHtml, {
req,
document: docWithoutBaseHref
});
} else {
res.render(indexHtml, {
req,
providers: [{ provide: APP_BASE_HREF, useValue: clientBaseHref }],
document: docWithBaseHref
})
}
As you can see by the name of the variables docWithoutBaseHref and docWithBaseHref we also manually parse the index file to add and remove the base href according to the domain and base href from the request.
I look it up in the code for v19 and the base href is retrieved from the html generated on the bundling process by the .handle(req) method from AngularNodeAppEngine, this break our app because we need to put the base href that came from the SSR request, instead of reading from a static file.
Is there a possibility to have this again working with Angular?
We tested with commonEngine and it has the same capabilities from ngExpressEngine.
The problem is that I don't think the angular team will maintain multiple packages, considering that the Server routes it's supported only by AngularNodeAppEngine and it will be the future of angular SSR and the other options will be deprecated.
We would like to know if something like this will be considered to be supported by AngularNodeAppEngine?
We can still keep using the packages/code that allow our customization, but this will only delay the problem and will force us to stay attached to an older version of angular. And prevent the use of new features.
We rely on this information to make a decision about how to move forward.
Thanks.
Cheers.
Proposed solution
Allow for customization of html files from the SSR server instead of using hard coded values.
Allow to provide dynamic base href from SSR to the rendering of an angular route.
Alternatives considered
Keep using an older angular version and never upgrade.
Move to another framework.
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 16h 35m
- PR unite (30g)
- 176
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular-cli
-
area: @angular/build gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/angular-cli#33055 · 1 commento · 3 reazioni ·
-
unit-test: with --coverage, a setup file's hooks reach only the first spec file of each worker Apertaarea: @angular/build gemini-triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 assegnatario ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 assegnatario ·
Tutte le issue di angular/angular-cli
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
dennys-bd/agent-hive#184 ·
-
Add: hunch Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
AbdelStark/awesome-typesafe#104 ·
-
ai-observability bug team/ai-observability
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vicharanashala/fln#563 ·