Angular express应用程序中的两个应用程序(错误:无法匹配任何路由。URL段:)

Angular express应用程序中的两个应用程序(错误:无法匹配任何路由。URL段:),angular,express,Angular,Express,嗨(对不起,我的英语不是我的母语) 我在express中运行了一个angular应用程序,并决定为管理员和用户使用一个单独的angular应用程序(基本上是因为我在导航栏中获得了太多的路线) 当我使用“ng serve”(每个应用都有自己的导航)分别运行它们时,我现在有两个应用程序运行良好。当我尝试将这两个应用程序都放入express时,问题出现了 我就这样做了, routes/index.js文件包含以下内容 router.route('/') .options( (req, res) =&g

嗨(对不起,我的英语不是我的母语)

我在express中运行了一个angular应用程序,并决定为管理员和用户使用一个单独的angular应用程序(基本上是因为我在导航栏中获得了太多的路线) 当我使用“ng serve”(每个应用都有自己的导航)分别运行它们时,我现在有两个应用程序运行良好。当我尝试将这两个应用程序都放入express时,问题出现了

我就这样做了,

routes/index.js文件包含以下内容

router.route('/')
.options( (req, res) => {
    res.sendStatus(200);
})
.get( (req, res, next) => {
    //res.render('index', { title: 'Express' });

  res.sendFile(path.join(__dirname,"../gbv/index.html"));
});

...
router.route('/admin')
.options( (req, res) => {
  res.sendStatus(200);
})
.get( (req, res, next) => {
     //res.render('index', { title: 'Express' });

  res.sendFile(path.join(__dirname,"../admin/index.html"));
  return;

});
我访问我的站点http:localhost/没有问题,但是当我访问http:localhost/admin时,我遇到了以下错误:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'admin'
第一个app1的导航仍然相同

很遗憾,我还不能展示照片

奇怪的是,通过检查网络控制台,我可以检查文件是否被发送。 看起来如果第一个app1的导航仍然存在,而不是带来app2的导航。 我怀疑这与这两个文件名为index.html这一事实有关,这将导致混淆。在执行“ng构建”之前,我尝试更改输出文件的名称。但是angular不允许我这么做

我使用的是express 4.16.1 角度10.2.2


有人有同样的问题吗?

xD出于某种原因,它可以通过更改为

app.use(express.static(path.join(__dirname, 'gbv')));
app.use(express.static(path.join(__dirname, 'admin')));
和使用

ng build --output-hashing all
当构建内置的角度

ng build --output-hashing all