2017-10-18 147 views
0

我使用IIS版本6.1 SP1将我的Angular项目部署到我们的开发环境,并且在路由参数上收到403 Forbidden错误。在我的URL中,“客户端”不是一个组件,而是一个路由参数。该项目在我的本地主机上工作得很好,只是当我将代码推送到我们的开发环境时才会出现问题。Angular 4 403使用IIS禁用路由参数

enter image description here 这是我在app.routes.ts代码:

const routes: Routes = [ 
    { 
     path: '', 
     redirectTo: 'login', 
    pathMatch: 'full' 
}, 
{ 
    path: 'login', 
    component: LoginComponent 
}, 
{ 
    path: 'login/:licenseeCode', 
    component: LoginComponent 

}, 
... 
+1

我不认为角路由是足够的信息告诉你问题出在哪里或是什么。这看起来很好;你甚至没有任何可能阻止人们查看组件的警卫。如果它在本地和生产环境中不同,它显然是应用程序外部的一些东西。 – jonrsharpe

回答

1

如果部署到一个文件夹(不是root),你可能需要调整您的

<base href="/FOLDER_WHERE_YOU_DEPLOYED/" /> 

也尝试添加这对你的配置文件:

<system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="AngularJS Routes" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="/FOLDER_WHERE_YOU_DEPLOYED/" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
+0

这正是我刚发现的。当我建立我的项目时,我不得不添加--base-href/LPPortal2 /并相应地修改了重写。谢谢 –