【发布时间】:2018-10-25 15:39:11
【问题描述】:
我有 Angular 6 应用程序和 WebAPI。我已经在 IIS 上和 Angular 应用程序下部署了 Angular 应用程序,我为 API 创建了应用程序。
类似的东西
IIS
|
|-Angular6App(port:443)
|
|-ServiceAPI
这背后的想法是使用相同的 DNS。因此,当调用 https://Angular6App.com 时,它应该加载 Angular 应用程序。如果https://Angular6App.com/ServiceApi/api/cntlr/id被调用,它应该得到数据(意思是调用api服务)。
所以现在当我调用https://Angular6App.com/ServiceApi/api/cntlr/id 时,它正在从 Angular 应用程序加载默认路由。实际上我想在调用 api 时跳过角度路由。
Angular 应用中的路由
[
{ path: '', redirectTo: 'A', pathMatch: 'full' },
{ path: 'A', component: AComponent, canActivate: [AuthGuard] },
{ path: 'B', component: BComponent, canActivate: [AuthGuard] },
]
请让我知道我是否可以这样做以及如何做到这一点?
谢谢 --cc
【问题讨论】:
-
分享你的代码。
-
我认为使用 Web Api 部署 Angular 生产静态文件是一种很好的技术,因为我已经使用 Spring Boot 和 Express 部署了 Angular 应用程序,两者都采用了它们部署静态文件的独特方式.而我们只需要通过 ng build —prod 将构建 Angular 应用程序生成的文件,即 dist 文件夹中的文件复制到 speingboot 或 express 的这个静态区域
-
您的应用中是否定义了其他路由?感觉就像你有一个匹配
**路径并使用默认路由的组件或重定向到默认路由。 -
@DanielWSrimpel 除了 {path: 'logout', component: LogoutComponent} 之外,我没有指定任何其他路由。
-
@AbhishekKumar 我确实是从 dist 复制的。 API 和 Angular 在部署为不同的站点/应用程序时有效。问题是当我在 IIS 中的 Angular 下创建 API 应用程序时。(调用 API 时重定向到默认路由)