忽略Angular 9中的路线?

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

我正在尝试让我的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代码调用API。在我看来,Angular代码“捕捉”了我对API的调用。如何在...

angular angular2-routing iis-10
1个回答
0
投票

您正在寻找的是angular proxy-config选项。这样一来,您就可以根据需要重新路由api调用,并在运行或构建过程中调用它,例如ng serve --proxy-config proxy.conf.json

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