在 angular 15 中如何通过 ng serve 设置 base href?

问题描述 投票:0回答:0

我有一个场景,我将 HTTP 流量从我的集群重定向到我的本地机器,当我这样做时,我需要将索引文件中的 base 属性设置为一个路径,因此 Index.html 应该看起来像

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ukcustoms</title>
  <base href="/web/mypath/">
  ... other stuff
  
</html>

现在在角度上你曾经可以通过 ng serve 做到这一点

ng 服务 --host 0.0.0.0 --disable-host-check --port 4203 --base-href /网络/我的路径/

事实上,--base-href 参数在 ng build 中仍然运行良好,它适用于我的代码集群版本。

谁能告诉我是否还有办法通过 ng serve 做到这一点?

我尝试过的事情都导致了一个以“/”为基础的索引文件

我试过的

  • 编辑 index.html 文件以包含路径
  • 将 APP_BASE_HREF 添加到 ngModule
angular angular-cli
© www.soinside.com 2019 - 2024. All rights reserved.