angular - 如何在 Azure 部署上通过刷新解决 Angular 路由问题
问题描述
我有一个要部署到 Azure 云的 Angular(v7) 项目。我遇到路由问题。当我在其中一个子页面上刷新页面时,我得到:“您要查找的资源已被删除、名称已更改或暂时不可用。”
我看的是部署部署指令的角度指令
我也阅读了很多关于该问题的帖子,但我没有找到适合我的解决方案。
我的路由规则很简单。
export const AdminLayoutRoutes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{ path: 'dashboard', component: DashboardComponent },
{ path: 'contracts', component: ContractsComponent }
];
我在“Src”文件夹中创建了 web.config 文件,内容如下:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
也放入 index.html
<base href='/'>
它没有帮助。还有什么可以检查的吗?
解决方案
推荐阅读
- sql - 确定某个值是否第一次出现在列中
- python - 在不应该的情况下返回 None
- php - 通过 $_GET 方法从 ajax 中的 php 文件的标题中获取值
- c# - 可编辑组合框无法正常工作
- smtpclient - NodeMailer - SMTP 传输连接池
- python - 在python中有效地使用来自csv的数据生成对象
- python - 如何使用 Pandas 获得增加值的平均值?
- ruby-on-rails - 使用带有 Rails4 的 Searchkick 导入记录时,如何强制预先加载关联?
- html - bootstrap 4中的重叠列
- reactjs - 如何从 React Native 中的包中动态获取数据