Angular 4 403 Forbidden on route parameter with IIS

编程入门 行业动态 更新时间:2024-10-28 20:23:40
本文介绍了Angular 4 403 Forbidden on route parameter with IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我使用 IIS 版本 6.1 SP1 将我的 Angular 项目部署到我们的开发环境,但我的路由参数出现 403 Forbidden 错误.在我的 URL 中,客户端"不是组件而是路由参数.该项目在我的本地主机上运行良好,只有当我将代码推送到我们的开发环境时才会出现问题.

I deployed my Angular project to our dev environment using IIS Version 6.1 SP1 and I'm getting 403 Forbidden error on my route parameter. In my URL, the "client" is not a component but a route parameter. The project works perfectly fine on my localhost, the issue is only when I pushed the code to our development environment.

这是我在 app.routes.ts 中的代码:

Here is my code in app.routes.ts:

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

},
...

推荐答案

如果您部署到文件夹(非 ROOT),您可能需要调整您的

if you deployed to a folder (NOT ROOT) you might need to adjust your

<base href="/FOLDER_WHERE_YOU_DEPLOYED/" />

还尝试将其添加到您的配置文件中:

also try adding this to your config file:

<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>

这篇关于Angular 4 403 Forbidden on route parameter with IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 04:04:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/996174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Forbidden   Angular   IIS   parameter   route

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!