【发布时间】:2020-09-27 20:32:00
【问题描述】:
我正在尝试让我的 Angular 代码调用 API。
在我看来,Angular 代码“捕获”了我对 API 的调用。如何指示 Angular 应用程序将请求“传递”到 IIS 中的 Web 应用程序?
我将 Angular 应用程序部署到位于根目录的网站,例如 www.dummy.com。 我在 www.dummy.com/IDP 有一个身份服务器作为 Web 应用程序运行,并且 在 www.dummy.com/API 调用的单一 API。
如果相对路由以 IDP 或 API 开头,我希望各自的 Web 应用程序处理它们。
我该怎么做?
我已经尝试过解决 IIS 上的 URL 重写和 ARR,但我更喜欢代码中的解决方案。
const routes: Routes = [
{path: '', redirectTo: 'travel-expenses', pathMatch: 'full'},
{path: 'fetch-data', component: FetchDataComponent},
{path: 'sign-in', component: SignInComponent},
{path: 'signin-redirect-callback', component: SigninRedirectCallbackComponent},
{path: 'signout-redirect-callback', component: SignoutRedirectCallbackComponent},
{path: 'unauthorized', component: UnauthorizedComponent},
{
path: 'travel-expenses',
loadChildren: () => import('./modules/travel-expenses/travel-expenses.module').then(m => m.TravelExpensesModule),
canActivate: [UserSignedInGuard]
},
{path: '404', component: PageNotFoundComponent},
{path: '**', redirectTo: '/404'}
];
【问题讨论】:
-
您是如何提出请求的?是什么让你认为 Angular 正在追赶他们?什么负责路由?
-
Rel 角度路由:api/ 和 idp/。 api中的相对路由:../idp/
-
jonrsharpe:我通过对 Web 根目录的请求访问了 Angular 应用程序。显示很好。然后尝试使用 IDP 登录。它使用本地主机和不同的端口在本地工作,但不在服务器上工作。 IDP 有一个网页,但导航到 www.dummy.com/IDP 会显示应用页面和 404。我添加了带有路由的 sn-p,
-
你能分享你的服务器配置,你是如何部署角度应用程序的吗?我猜它与服务器有关,如果你直接在浏览器中打开这个 ww.dummy.com/IDP 然后重定向到 Angular 应用程序,那么我想需要在服务器中添加一些点,为这个端点做一些自定义的事情
标签: angular angular2-routing iis-10