【发布时间】:2026-01-05 15:05:02
【问题描述】:
我有一个 Angular 6 应用程序部署到 Firebase,但是,当我转到已将应用程序部署到的 url 时,它不会重定向到 index.html。它只显示查看文档页面。
但是,如果我最后用 /index.html 键入地址,它就可以完美运行。
这是我的 firebase json:
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
这是我的角度路由:
const appRoutes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'add-recipe', component: AddrecipeComponent },
{ path: 'edit-recipe/:id', component: EditrecipeComponent },
{ path: 'recipe-detail/:id', component: RecipedetailComponent },
{ path: 'shopping-list', component: ShoppinglistComponent },
{ path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{ path: '**', component: HomeComponent }
];
在我的 index.html 文件中,这是我的基本 href:
<base href="/">
在配置过程中,我勾选了这是一个单页应用程序的选项。
感谢您的帮助。
编辑:当我用 localhost 测试它时,它完美地重定向。
【问题讨论】:
标签: angular firebase routing firebase-hosting