Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Dynamic base href (APP_BASE_HREF) for SSR

オープン
#29,449 コメント 6 件 リアクション 11 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
angular, typescript
領域
backend, web-dev

調査の方向性

まず AngularNodeAppEngine.handle を読み、base-href の処理を既存の CommonEngine と ngExpressEngine の動作と比較します。APP_BASE_HREF とリクエストがどのように SSR レンダリングまで到達するかを追跡し、そのうえで、リクエスト固有の base href をサポートするには何が必要かを定義します。リクエストから提供された base href を、index ファイルを手動で解析せずに SSR 出力で使用できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area: @angular/ssr feature feature: insufficient votes
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.

主要言語
TypeScript
スター
27k
フォーク
11.8k
平均マージ
17時間 25分
マージ済み PR(30日)
183

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular-cli のほかの issue

angular/angular-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。