【发布时间】:2021-06-28 23:30:43
【问题描述】:
我有一个使用 github 页面部署的站点,有时我收到 404 错误,这也发生在使用 ng serve --open 的 localhost 中
如果您是第一次尝试进入此页面,可能会遇到 404 错误:https://maximegillot.github.io/formation/kafka
但是如果你去主页:https://maximegillot.github.io/ 并手动导航到 /formation/kafka 你可能不会有任何问题......
当我使用ng serve --open部署我的站点时,我也遇到了这个问题
我觉得这个问题是随机的,我不知道从哪里开始调查。
要部署我只需使用 ng build --aot --vendor-chunk --common-chunk --delete-output-path --build-optimizer 并在 github 上发布 /dist/mgi-site/*:https://github.com/MaximeGillot/MaximeGillot.github.io
我的index.html
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gillot Maxime</title>
<base href="/">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"/>
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet"
type="text/css"/>
<link rel="icon" type="image/x-icon" href="assets/favicon.ico"/>
<script src="https://use.fontawesome.com/releases/v5.15.3/js/all.js" crossorigin="anonymous">
...
</head>
<body>
<app-root></app-root>
</body>
</html>
文件app-routing.module.ts:
const routes: Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: 'formation/nifi', component: FormationNifiComponent},
{path: 'formation/kafka', component: FormationKafkaComponent},
{path: 'home', component: MainComponent},
{path: 'cv', component: CvComponent},
{path: 'projets', component: ProjetComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
【问题讨论】:
-
能否提供整个app.module.ts?
-
这能回答你的问题吗? Deploy Angular 7 to github pages
标签: html angular routes github-pages