diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-26 08:54:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-26 08:54:19 +0200 |
commit | ca00baa75ae849b1ba4953f0ff843ff5452f6745 (patch) | |
tree | 8d90d25a9c5ec9eb14a25011c8a23138c11eda55 | |
parent | 365d9083c938ea128e04c4f98e6b18dd26d86dd2 (diff) | |
download | PeerTube-ca00baa75ae849b1ba4953f0ff843ff5452f6745.tar.gz PeerTube-ca00baa75ae849b1ba4953f0ff843ff5452f6745.tar.zst PeerTube-ca00baa75ae849b1ba4953f0ff843ff5452f6745.zip |
Avoid 404 when changing language
-rw-r--r-- | client/src/app/app-routing.module.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index a39be17dc..d3cdcefea 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router' | 2 | import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router' |
3 | import { AppComponent } from '@app/app.component' | ||
4 | import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' | 3 | import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' |
5 | import { MenuGuards } from '@app/core/routing/menu-guard.service' | 4 | import { MenuGuards } from '@app/core/routing/menu-guard.service' |
6 | import { PreloadSelectedModulesList } from './core' | 5 | import { PreloadSelectedModulesList } from './core' |
7 | import { EmptyComponent } from './empty.component' | 6 | import { EmptyComponent } from './empty.component' |
7 | import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' | ||
8 | 8 | ||
9 | const routes: Routes = [ | 9 | const routes: Routes = [ |
10 | { | 10 | { |
@@ -56,13 +56,22 @@ const routes: Routes = [ | |||
56 | { | 56 | { |
57 | path: '', | 57 | path: '', |
58 | component: EmptyComponent // Avoid 404, app component will redirect dynamically | 58 | component: EmptyComponent // Avoid 404, app component will redirect dynamically |
59 | }, | ||
60 | { | ||
61 | path: '**', | ||
62 | loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) | ||
63 | } | 59 | } |
64 | ] | 60 | ] |
65 | 61 | ||
62 | // Avoid 404 when changing language | ||
63 | for (const locale of POSSIBLE_LOCALES) { | ||
64 | routes.push({ | ||
65 | path: locale, | ||
66 | component: EmptyComponent | ||
67 | }) | ||
68 | } | ||
69 | |||
70 | routes.push({ | ||
71 | path: '**', | ||
72 | loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) | ||
73 | }) | ||
74 | |||
66 | @NgModule({ | 75 | @NgModule({ |
67 | imports: [ | 76 | imports: [ |
68 | RouterModule.forRoot(routes, { | 77 | RouterModule.forRoot(routes, { |