fix(router): fixing sub path refresh issue on gh-pages

Reference: Step 5. https://medium.com/swlh/how-to-host-your-angular-reactjs-vuejs-spa-on-github-pages-2d9ab102ac7b
This commit is contained in:
Joohansson 2020-07-30 17:46:24 +02:00
commit 626012cb15
3 changed files with 12 additions and 1 deletions

View file

@ -19,7 +19,8 @@
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/pow.wasm"
"src/pow.wasm",
"src/404.html"
],
"styles": [
"src/styles.less"

5
src/404.html Normal file
View file

@ -0,0 +1,5 @@
<script>
const path = window.location.pathname.slice(1);
localStorage.setItem('path', path);
window.location.href='../';
</script>

View file

@ -58,6 +58,11 @@ export class AppComponent implements OnInit {
private ledger: LedgerService,
public price: PriceService) {
router.events.subscribe(() => { this.navExpanded = false })
let path = localStorage.getItem('path');
if(path) {
localStorage.removeItem('path');
this.router.navigate([path]);
}
}
async ngOnInit() {