部署到服务器以获取特定于路由的URL后未找到角文件

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

我的角度应用程序可以在我的本地主机上完美运行:4200。现在,我已将其部署到服务器。 homepage看起来还不错。由于网址无效,它重定向到错误页面。该页面的有效网址为this.

如果url在我的本地计算机上通过了两个路由参数,但由于某些原因,它在实时服务器上不起作用,我将获得有效的页面。

const routes: Routes = [
  {
    path:":restaurantId/:mobileNo",
    component: LandingComponent,
  },
  {
    path:"",
    component: LandingComponent,
    canActivate: [AuthGuard]

  },
  {
    path:"error",
    component: ErrorComponent,
  },
];

index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Freshii</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
</body>
</html>
angular url angular-routing angular-router
2个回答
1
投票

这是因为您正尝试直接访问该URL,并且您的服务器没有有关此溃逃的任何信息。只有您的角度应用程序才能识别该溃败。由于我现在不知道您的服务器配置,因此我无法为您提供确切的解决方案。但是,如果它是Apache,则可以创建htaccess文件并添加onfigration,使其首先出现在index.html上,然后引发错误


0
投票

对此服务器ngix进行此配置后,现在已修复。

proxy and location configuration

© www.soinside.com 2019 - 2024. All rights reserved.